From 37570255d89fbd72ec30b1f787703e55171a597c Mon Sep 17 00:00:00 2001 From: mvl22 Date: Tue, 10 Apr 2018 18:54:09 +0100 Subject: [PATCH 1/3] In GeoJSON, fix feature_collection validation --- lib/map_print/geo_json_handler.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/map_print/geo_json_handler.rb b/lib/map_print/geo_json_handler.rb index 8649e74..c463cd8 100644 --- a/lib/map_print/geo_json_handler.rb +++ b/lib/map_print/geo_json_handler.rb @@ -72,7 +72,7 @@ def feature(geometry, properties={}) def feature_collection(features) features.each do |object| - feature(object) + feature(object['geometry'], object['properties']) end end From 6783cd2cdd45917351fafdce90312f41011cb4fc Mon Sep 17 00:00:00 2001 From: mvl22 Date: Tue, 10 Apr 2018 18:54:33 +0100 Subject: [PATCH 2/3] In GeoJSON, enable LineString and Polygon to pass through validate_feature, rather than always fail --- lib/map_print/geo_json_handler.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/map_print/geo_json_handler.rb b/lib/map_print/geo_json_handler.rb index c463cd8..37bcfb1 100644 --- a/lib/map_print/geo_json_handler.rb +++ b/lib/map_print/geo_json_handler.rb @@ -41,6 +41,8 @@ def draw_geojson def validate_feature(geometry, properties) raise NoGeometryPresent.new("No geometry present for this feature") if geometry.nil? case geometry['type'] + when 'LineString', 'Polygon' + # No checks needed when 'Point' if properties.nil? || properties['image'].nil? raise NoPointImage.new("Missing image in point geometry") From 0d264baa565318aa00a926d9f720c16f9449eae3 Mon Sep 17 00:00:00 2001 From: mvl22 Date: Tue, 10 Apr 2018 19:30:38 +0100 Subject: [PATCH 3/3] Fix coordinates in GeoJSON example - GeoJSON order is lng,lat --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 5b6206d..e306b03 100644 --- a/README.md +++ b/README.md @@ -126,20 +126,20 @@ map_configuration = { urls: ['http://a.tile.thunderforest.com/transport/${z}/${x}/${y}.png'], # currently only one is being used, in the future it will load balance level: 1, # used to order the layer appearance opacity: 1.0 # in case you want the layer to have some transparency - }], # see geojson specification for feature/object support. See http://leafletjs.com/reference.html#path-options for formatting options, the following attributes under properties are supported: `stroke, color, weight, opacity, fill, fillColor, fillOpacity, fillRule, dashArray, lineCap, lineJoin` + }], # see GeoJSON specification for feature/object support. See http://leafletjs.com/reference.html#path-options for formatting options, the following attributes under properties are supported: `stroke, color, weight, opacity, fill, fillColor, fillOpacity, fillRule, dashArray, lineCap, lineJoin` geojson: '{ "type": "FeatureCollection", "features": [{ "type":"Feature", - "geometry":{"type":"Point", "coordinates":[-32.026862,-55.425003]}, + "geometry":{"type":"Point", "coordinates":[-55.425003,-32.026862]}, "properties":{"image": "./marker.png"} }, { "type": "Feature", - "geometry": {"type": "LineString", "coordinates": [ [-32.026862,-55.425003], [-31.026862,-55.425003], [-31.026862,-54.425003], [-32.026862,-54.425003] ] }, + "geometry": {"type": "LineString", "coordinates": [ [-55.425003,-32.026862], [-55.425003,-31.026862], [-54.425003,-31.026862], [-54.425003,-32.026862] ] }, "properties": {"color": "#000000"} }, { "type": "Feature", - "geometry": {"type": "Polygon", "coordinates": [ [-32.126862,-55.825003], [-31.426862,-55.225003], [-31.326862,-54.825003], [-32.146862,-54.835003] ] }, + "geometry": {"type": "Polygon", "coordinates": [ [-55.825003,-32.126862], [-55.225003,-31.426862], [-54.825003,-31.326862], [-54.835003,-32.146862] ] }, "properties": { "stroke": true, "color": "#000000",