Skip to content

Commit ecc79d4

Browse files
committed
geojson support
1 parent 5fd5f5b commit ecc79d4

4 files changed

Lines changed: 12 additions & 10 deletions

File tree

dist/gridviz.js

Lines changed: 2 additions & 1 deletion
Large diffs are not rendered by default.

examples/basics/geojson.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
//make geojson layer
1919
const geojsonLayer = new gridviz.GeoJSONLayer({
2020
url: 'https://raw.githubusercontent.com/eurostat/gridviz/master/examples/basics/geojson_test.json',
21-
//shape: (f, z) => (f.properties.id.includes('DE') ? 'square' : 'circle'),
21+
shape: (f, z) => (f.properties.name == 'Fox' ? 'circle' : 'square'),
2222
//size: (f, z) => Math.max(2, 10000 / z),
2323
//strokeStyle: (f, z) => 'black',
2424
//fillStyle: (f, z) => 'red',

examples/basics/geojson_test.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
"name": "geojson_test",
44
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:EPSG::3035" } },
55
"features": [
6-
{ "type": "Feature", "properties": { "name": "Amber Fox", "value": 17 }, "geometry": { "type": "Point", "coordinates": [ 4046000.0, 2654000.0 ] } },
7-
{ "type": "Feature", "properties": { "name": "Blue Cedar", "value": 42 }, "geometry": { "type": "MultiPoint", "coordinates": [ [ 4046200.0, 2654000.0 ], [ 4046250.0, 2654050.0 ], [ 4046300.0, 2653980.0 ] ] } },
8-
{ "type": "Feature", "properties": { "name": "Crimson Lake", "value": 85 }, "geometry": { "type": "LineString", "coordinates": [ [ 4046500.0, 2653900.0 ], [ 4046600.0, 2653950.0 ], [ 4046700.0, 2653920.0 ], [ 4046800.0, 2653980.0 ] ] } },
9-
{ "type": "Feature", "properties": { "name": "Delta Pine", "value": 23 }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [ 4047000.0, 2654100.0 ], [ 4047100.0, 2654200.0 ], [ 4047200.0, 2654150.0 ] ], [ [ 4047000.0, 2654300.0 ], [ 4047100.0, 2654350.0 ], [ 4047200.0, 2654320.0 ] ] ] } },
10-
{ "type": "Feature", "properties": { "name": "Emerald Sky", "value": 64 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 4047500.0, 2653900.0 ], [ 4047700.0, 2653900.0 ], [ 4047700.0, 2654100.0 ], [ 4047500.0, 2654100.0 ], [ 4047500.0, 2653900.0 ] ] ] } },
11-
{ "type": "Feature", "properties": { "name": "Ivory Forest", "value": 58 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 4047304.776716627180576, 2653313.536672802641988 ], [ 4047704.776716627180576, 2653313.536672802641988 ], [ 4047704.776716627180576, 2653713.536672802641988 ], [ 4047304.776716627180576, 2653713.536672802641988 ], [ 4047304.776716627180576, 2653313.536672802641988 ] ], [ [ 4047404.776716627180576, 2653413.536672802641988 ], [ 4047504.776716627180576, 2653413.536672802641988 ], [ 4047504.776716627180576, 2653513.536672802641988 ], [ 4047404.776716627180576, 2653513.536672802641988 ], [ 4047404.776716627180576, 2653413.536672802641988 ] ], [ [ 4047554.776716627180576, 2653538.536672802641988 ], [ 4047654.776716627180576, 2653538.536672802641988 ], [ 4047654.776716627180576, 2653638.536672802641988 ], [ 4047554.776716627180576, 2653638.536672802641988 ], [ 4047554.776716627180576, 2653538.536672802641988 ] ] ] } },
12-
{ "type": "Feature", "properties": { "name": "Golden River", "value": 91 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 4048000.0, 2653900.0 ], [ 4048150.0, 2653900.0 ], [ 4048150.0, 2654050.0 ], [ 4048000.0, 2654050.0 ], [ 4048000.0, 2653900.0 ] ] ], [ [ [ 4048250.0, 2653900.0 ], [ 4048400.0, 2653900.0 ], [ 4048400.0, 2654050.0 ], [ 4048250.0, 2654050.0 ], [ 4048250.0, 2653900.0 ] ] ] ] } },
13-
{ "type": "Feature", "properties": { "name": "Hidden Stone", "value": 58 }, "geometry": { "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [ 4048700.0, 2654000.0 ] }, { "type": "LineString", "coordinates": [ [ 4048750.0, 2653950.0 ], [ 4048850.0, 2654050.0 ] ] }, { "type": "Polygon", "coordinates": [ [ [ 4048900.0, 2653900.0 ], [ 4049000.0, 2653900.0 ], [ 4049000.0, 2654000.0 ], [ 4048900.0, 2654000.0 ], [ 4048900.0, 2653900.0 ] ] ] } ] } }
6+
{ "type": "Feature", "properties": { "name": "Fox", "value": 17 }, "geometry": { "type": "Point", "coordinates": [ 4046000.0, 2654000.0 ] } },
7+
{ "type": "Feature", "properties": { "name": "Cedar", "value": 42 }, "geometry": { "type": "MultiPoint", "coordinates": [ [ 4046200.0, 2654000.0 ], [ 4046250.0, 2654050.0 ], [ 4046300.0, 2653980.0 ] ] } },
8+
{ "type": "Feature", "properties": { "name": "Lake", "value": 85 }, "geometry": { "type": "LineString", "coordinates": [ [ 4046500.0, 2653900.0 ], [ 4046600.0, 2653950.0 ], [ 4046700.0, 2653920.0 ], [ 4046800.0, 2653980.0 ] ] } },
9+
{ "type": "Feature", "properties": { "name": "Pine", "value": 23 }, "geometry": { "type": "MultiLineString", "coordinates": [ [ [ 4047000.0, 2654100.0 ], [ 4047100.0, 2654200.0 ], [ 4047200.0, 2654150.0 ] ], [ [ 4047000.0, 2654300.0 ], [ 4047100.0, 2654350.0 ], [ 4047200.0, 2654320.0 ] ] ] } },
10+
{ "type": "Feature", "properties": { "name": "Sky", "value": 64 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 4047500.0, 2653900.0 ], [ 4047700.0, 2653900.0 ], [ 4047700.0, 2654100.0 ], [ 4047500.0, 2654100.0 ], [ 4047500.0, 2653900.0 ] ] ] } },
11+
{ "type": "Feature", "properties": { "name": "Forest", "value": 58 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ 4047304.776716627180576, 2653313.536672802641988 ], [ 4047704.776716627180576, 2653313.536672802641988 ], [ 4047704.776716627180576, 2653713.536672802641988 ], [ 4047304.776716627180576, 2653713.536672802641988 ], [ 4047304.776716627180576, 2653313.536672802641988 ] ], [ [ 4047404.776716627180576, 2653413.536672802641988 ], [ 4047504.776716627180576, 2653413.536672802641988 ], [ 4047504.776716627180576, 2653513.536672802641988 ], [ 4047404.776716627180576, 2653513.536672802641988 ], [ 4047404.776716627180576, 2653413.536672802641988 ] ], [ [ 4047554.776716627180576, 2653538.536672802641988 ], [ 4047654.776716627180576, 2653538.536672802641988 ], [ 4047654.776716627180576, 2653638.536672802641988 ], [ 4047554.776716627180576, 2653638.536672802641988 ], [ 4047554.776716627180576, 2653538.536672802641988 ] ] ] } },
12+
{ "type": "Feature", "properties": { "name": "River", "value": 91 }, "geometry": { "type": "MultiPolygon", "coordinates": [ [ [ [ 4048000.0, 2653900.0 ], [ 4048150.0, 2653900.0 ], [ 4048150.0, 2654050.0 ], [ 4048000.0, 2654050.0 ], [ 4048000.0, 2653900.0 ] ] ], [ [ [ 4048250.0, 2653900.0 ], [ 4048400.0, 2653900.0 ], [ 4048400.0, 2654050.0 ], [ 4048250.0, 2654050.0 ], [ 4048250.0, 2653900.0 ] ] ] ] } },
13+
{ "type": "Feature", "properties": { "name": "Stone", "value": 58 }, "geometry": { "type": "GeometryCollection", "geometries": [ { "type": "Point", "coordinates": [ 4048700.0, 2654000.0 ] }, { "type": "LineString", "coordinates": [ [ 4048750.0, 2653950.0 ], [ 4048850.0, 2654050.0 ] ] }, { "type": "Polygon", "coordinates": [ [ [ 4048900.0, 2653900.0 ], [ 4049000.0, 2653900.0 ], [ 4049000.0, 2654000.0 ], [ 4048900.0, 2654000.0 ], [ 4048900.0, 2653900.0 ] ] ] } ] } }
1414
]
1515
}

src/layer/GeoJSONLayer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export class GeoJSONLayer extends Layer {
118118
//get style parameters for the point feature
119119
const shape = this.shape(f, z)
120120
if (!shape || shape == 'none') return
121+
console.log('shape:', shape, 'name', f.properties.name)
121122
const size = this.size(f, z) * z
122123
if (!size) return
123124

0 commit comments

Comments
 (0)