Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[NOT READY] GeoJSON support #170

Closed
wants to merge 35 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
40e3372
variant : add binary visitation support
artemp May 5, 2014
57b45c2
first cut of GeoJSON parsing & rendering
incanus May 7, 2014
2b9fbb0
squashed stylequest merge
incanus May 7, 2014
e76bd03
refs #147: basic "locate me" button in debug UI
incanus May 8, 2014
115afe3
add relaxed comparsion function + tests
kkaefer May 8, 2014
7f4f327
make sure we're not converting too relaxedly
kkaefer May 8, 2014
d59aedc
don't show warnings in boost
kkaefer May 8, 2014
ee55798
remove debug code and use unary visitor directly
kkaefer May 8, 2014
c4067e2
Update README.md
May 8, 2014
895977a
setup-libraries: improve dependency checking
May 8, 2014
70a7ba8
ensure resources.cpp is included in xcode project - closes #175
May 8, 2014
0bfd7b0
Calculate clip IDs with a huffman prefix tree
kkaefer May 9, 2014
604e558
add missing include header
kkaefer May 10, 2014
d964128
make sure node is available
kkaefer May 12, 2014
b705382
add cross compile build script
kkaefer May 12, 2014
16e8d81
Merge branch 'master' of https://github.com/mapbox/llmr-native
kkaefer May 12, 2014
6136ab6
draw by layer, not by tile
kkaefer May 12, 2014
6ebb4c2
clean up gl::group() structure
kkaefer May 12, 2014
d9d9b28
disable texture deleting for now
kkaefer May 12, 2014
2a3377c
fix typo
kkaefer May 12, 2014
2b14579
only paint layer if it has data
kkaefer May 12, 2014
263c887
don't try to render layers that do not produce anyting during the cur…
kkaefer May 12, 2014
b6d6c7e
re-add iOS Xcode instructions
incanus May 12, 2014
6538f58
ensure setup-libraries.sh checks for valid pkg-config
May 12, 2014
bc29ed5
refs #166: fix for std::stoll et al. not handling strings
incanus May 12, 2014
38e7682
Merge branch 'master' of github.com:mapbox/llmr-native
incanus May 12, 2014
654520e
Revert "refs #166: fix for std::stoll et al. not handling strings"
incanus May 13, 2014
d8fa9aa
move weak_ptr list of tile_data objects to a map for faster lookups
kkaefer May 13, 2014
ab71db3
move tiles to std::map for faster lookups
kkaefer May 13, 2014
72c0410
save/restore state on ios
kkaefer May 13, 2014
b096373
abort rendering early if the style is disabled
kkaefer May 13, 2014
7bfcde4
split up painter into multiple files
kkaefer May 13, 2014
6668b9b
keep view controller self-contained for state save/restore
incanus May 13, 2014
5c89488
hide more API
incanus May 13, 2014
6972c40
Merge branch 'master' into geojson-work
incanus May 13, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ V ?= 1
all: llmr

# Builds the regular library
llmr: config.gypi llmr.gyp
llmr: config.gypi llmr.gyp node
deps/run_gyp llmr.gyp --depth=. -Goutput_dir=.. --generator-output=./build/llmr -f make
make -C build/llmr V=$(V) llmr-x86

node:
@if [ ! `which node` ]; then echo 'error: depends on node.js. please make sure node is on your PATH'; exit 1; fi;

##### Test cases ###############################################################

Expand Down Expand Up @@ -40,7 +42,7 @@ run-headless-test: build/test/Makefile


# Builds the linux app with make. This is also used by Travis CI
linux: config.gypi linux/llmr-app.gyp
linux: config.gypi linux/llmr-app.gyp node
deps/run_gyp linux/llmr-app.gyp --depth=. -Goutput_dir=.. --generator-output=./build/linux -f make
make -C build/linux V=$(V) linuxapp

Expand All @@ -52,17 +54,17 @@ run-linux: linux
##### Xcode projects ###########################################################

# build Mac OS X project for Xcode
xproj: config.gypi macosx/llmr-app.gyp
xproj: config.gypi macosx/llmr-app.gyp node
deps/run_gyp macosx/llmr-app.gyp --depth=. --generator-output=./build -f xcode
open ./build/macosx/llmr-app.xcodeproj

# build iOS project for Xcode
iproj: config.gypi ios/llmr-app.gyp
iproj: config.gypi ios/llmr-app.gyp node
deps/run_gyp ios/llmr-app.gyp --depth=. --generator-output=./build -f xcode
open ./build/ios/llmr-app.xcodeproj

# build Linux project for Xcode (Runs on Mac OS X too, but without platform-specific code)
lproj: config.gypi linux/llmr-app.gyp
lproj: config.gypi linux/llmr-app.gyp node
deps/run_gyp linux/llmr-app.gyp --depth=. --generator-output=./build -f xcode
open ./build/linux/llmr-app.xcodeproj

Expand All @@ -72,6 +74,10 @@ lproj: config.gypi linux/llmr-app.gyp
clean:
-rm -rf ./build/Release
-rm -rf ./build/Debug
-rm -f include/llmr/shader/shaders.hpp
-rm -f include/llmr/style/resources.hpp
-rm -f src/style/resources.cpp
-rm -rf ~/Library/Developer/Xcode/DerivedData/llmr*

distclean: clean
-rm -rf ./build
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ dependencies.

## OS X

Run `./setup_libraries.sh`
Run `./setup-libraries.sh`

This downloads all required dependencies, builds them and creates universal libraries that can be
used on both OS X and iOS.
Expand All @@ -36,9 +36,11 @@ To create projects, you can run:
## iOS

Because `libpng` isn't included in the iOS SDK, you will need to build a cross-architecture version
yourself. Run `./setup_libraries.sh`, which is derived from Mapnik's cross-architecture build
yourself. Run `./setup-libraries.sh`, which is derived from Mapnik's cross-architecture build
scripts. This will also run `./configure`.

Then, `make iproj` to create and open an Xcode project with an iOS-specific view controller housing and basic gesture support.

Target devices: iPhone 4 and above (4S, 5, 5c, 5s) and iPad 2 and above (3, 4, mini and/or retina).

## Ubuntu
Expand All @@ -60,7 +62,7 @@ Install glfw3 dependencies:

Build static dependencies:

./setup_libraries.sh
./setup-libraries.sh

This will automatically run configure for you and set the correct paths.

Expand Down
34 changes: 33 additions & 1 deletion bin/style.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

module.exports = {
"buckets": {
"route": {
"source": "geojson",
"type": "line"
},
"admin_maritime": {
"source": "mapbox streets",
"layer": "admin",
Expand Down Expand Up @@ -590,6 +594,9 @@ module.exports = {
"structure": [{
"name": "background",
"bucket": "background"
}, {
"name": "satellite",
"bucket": "satellite"
}, {
"name": "waterway_other",
"bucket": "waterway_other"
Expand Down Expand Up @@ -755,6 +762,9 @@ module.exports = {
}, {
"name": "bridge_major_rail_hatching",
"bucket": "bridge_major_rail"
}, {
"name": "route",
"bucket": "route"
}, {
"name": "admin_level_3",
"bucket": "admin_level_3"
Expand Down Expand Up @@ -840,6 +850,11 @@ module.exports = {
"background": {
"color": "land",
},
"route": {
"color": "#EC8D8D",
"width": 3,
"opacity": 0.5,
},
"admin_maritime": {
"color": "#cfe0fa",
"width": 4.5,
Expand Down Expand Up @@ -2054,7 +2069,24 @@ module.exports = {
"color": "maki",
"image": "beer-12",
"translate": "point_translate",
}
},
"satellite": {
"type": "raster",
"opacity": 0.25
},
}
}, {
"name": "satellite",
"layers": {
"building": {
"enabled": false,
},
"building_wall": {
"enabled": false,
},
"building_shadow": {
"enabled": false,
},
}
}],
"sprite": "/img/maki-sprite"
Expand Down
41 changes: 41 additions & 0 deletions include/llmr/map/geojson_source.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#ifndef LLMR_MAP_GEOJSON_SOURCE
#define LLMR_MAP_GEOJSON_SOURCE

#include <llmr/map/source.hpp>

#include <memory>

#include <rapidjson/document.h>

namespace llmr {

using JSVal = const rapidjson::Value&;
using Segment = std::vector<Coordinate>;
using GeoJSONTile = std::vector<Segment>;

class Map;
class Transform;

class GeoJSONSource : public Source, private util::noncopyable {
public:
GeoJSONSource(Map &map, Painter &painter, const char *url = "",
std::vector<uint32_t> zooms = {{ 1, 5, 9, 13 }}, uint32_t tile_size = 512,
uint32_t min_zoom = 1, uint32_t max_zoom = 13, bool enabled = true);

private:
rapidjson::Document parseJSON(const char* data);
void tile_GeoJSON(JSVal geojson);
void tile_feature(JSVal feature, std::shared_ptr<Transform>& transform);
std::map<Tile::ID, GeoJSONTile> tile_line_string(JSVal coords, std::shared_ptr<Transform>& transform, bool rejoin = false);

private:
std::map<Tile::ID, GeoJSONTile> all_tiles;
uint16_t tile_extent = 4096;
double padding = 0.01;
std::vector<std::shared_ptr<Transform>> transforms;

};

}

#endif
12 changes: 10 additions & 2 deletions include/llmr/map/map.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include <uv.h>

#include <llmr/map/view.hpp>
// #include <llmr/map/tile.hpp>
// #include <llmr/map/tile_data.hpp>
#include <llmr/map/transform.hpp>
#include <llmr/style/style.hpp>
#include <llmr/geometry/glyph_atlas.hpp>
Expand Down Expand Up @@ -94,6 +92,7 @@ class Map : private util::noncopyable {
inline GlyphAtlas &getGlyphAtlas() { return glyphAtlas; }
inline uv_loop_t *getLoop() { return loop; }
inline time getAnimationTime() const { return animationTime; }
inline Texturepool &getTexturepool() { return texturepool; }

private:
// uv async callbacks
Expand All @@ -106,13 +105,20 @@ class Map : private util::noncopyable {
void loadStyle(const uint8_t *const data, uint32_t bytes);

void updateTiles();
void updateClippingIDs();

size_t countLayers(const std::vector<LayerDescription>& layers);

// Prepares a map render by updating the tiles we need for the current view, as well as updating
// the stylesheet.
void prepare();

enum RenderPass { Opaque, Translucent };

// Unconditionally performs a render with the current map state.
void render();
void renderLayers(const std::vector<LayerDescription>& layers, RenderPass pass);
void renderLayer(const LayerDescription& layer_desc, RenderPass pass);

private:
// If cleared, the next time the render thread attempts to render the map, it will *actually*
Expand Down Expand Up @@ -141,6 +147,8 @@ class Map : private util::noncopyable {

bool debug = false;
time animationTime = 0;
float strata_thickness = 0.0f;
int strata = 0;

private:
bool async = false;
Expand Down
28 changes: 28 additions & 0 deletions include/llmr/map/raster_tile_data.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef LLMR_MAP_RASTER_TILE_DATA
#define LLMR_MAP_RASTER_TILE_DATA

#include <llmr/map/tile_data.hpp>

#include <llmr/renderer/raster_bucket.hpp>


namespace llmr {

class RasterTileData : public TileData {
friend class TileParser;

public:
RasterTileData(Tile::ID id, Map &map, const std::string url);
~RasterTileData();

virtual void parse();
virtual void render(Painter &painter, const LayerDescription& layer_desc);
virtual bool hasData(const LayerDescription& layer_desc) const;

protected:
RasterBucket bucket;
};

}

#endif
24 changes: 15 additions & 9 deletions include/llmr/map/source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
#include <llmr/util/noncopyable.hpp>
#include <llmr/util/time.hpp>

#include <list>
#include <forward_list>
#include <memory>
#include <vector>
#include <string>
#include <map>
#include <set>

namespace llmr {

Expand All @@ -22,21 +25,25 @@ class Source : public std::enable_shared_from_this<Source>, private util::noncop
public:
enum class Type {
vector,
raster
raster,
geojson
};

public:
Source(Map &map, Painter &painter, Texturepool &texturepool,
Source(Map &map, Painter &painter,
const char *url = "", Type type = Type::vector, std::vector<uint32_t> zooms = {0},
uint32_t tile_size = 512, uint32_t min_zoom = 0, uint32_t max_zoom = 14,
bool enabled = true);


Source::Type getType() const;

bool update();
void prepare_render(const TransformState &transform, bool is_baselayer = false);
void render(time animationTime);
size_t prepareRender(const TransformState &transform);
void render(const LayerDescription& layer_desc, const BucketDescription &bucket_desc);
void finishRender();

std::forward_list<Tile::ID> getIDs() const;
void updateClipIDs(const std::map<Tile::ID, ClipID> &mapping);

public:
bool enabled;
Expand All @@ -53,10 +60,9 @@ class Source : public std::enable_shared_from_this<Source>, private util::noncop

double getZoom() const;

private:
protected:
Map& map;
Painter& painter;
Texturepool& texturepool;

const Type type;
const std::vector<uint32_t> zooms;
Expand All @@ -65,8 +71,8 @@ class Source : public std::enable_shared_from_this<Source>, private util::noncop
const int32_t min_zoom;
const int32_t max_zoom;

std::forward_list<Tile> tiles;
std::forward_list<std::weak_ptr<TileData>> tile_data;
std::map<Tile::ID, std::unique_ptr<Tile>> tiles;
std::map<Tile::ID, std::weak_ptr<TileData>> tile_data;
};

}
Expand Down
Loading