Re: [mapserver-users] Apply style to geojson based on property in geojson data
Expressions are easy to mess up. To test if "value" is getting thru the drive try using it as a label. That might help you to narrow down the problem. LABELITEM "value" . . . CLASS . . . LABEL . . . END END On Wed, Oct 25, 2017 at 2:08 AM, Tuffawrote: > Hello Richard! > > > I haven't used geojson as a data source, but maybe if you shared a small > > example of your map file and the data it would help. > > Here's some more information > > mapfile.map (excerpt): > > LAYER > NAME "countries" > STATUS OFF > TYPE POLYGON > CONNECTIONTYPE OGR > CONNECTION "africa.geojson" > DATA "select * from africa" > CLASS STYLE OUTLINECOLOR "#ff" END END > CLASS EXPRESSION ([value] >= 0 AND [value] <= 100) STYLE COLOR > "#FFE397" END END > END > > I have tried numerous types of select statement in the DATA definition, but > have failed to influence the styling based on the ‘value’ property added to > the geojson file. Of course, this may have all been in vain, if the GDAL > driver does not support anything other than ‘select * from ’, but I > cannot tell from the documentation - MapServer, or GDAL - what is allowed. > > Here is an excerpt of the africa.geojson file, with the additional property > ‘value’ added. Following is the output from ogrinfo. > > { > "features": [ > { > "geometry": { > "coordinates": [ > [ > [ > [ > 8.621624, > 36.941797 > ], > [ > 8.621624, > 36.941797 > ] > ] > ] > ], > "type": "MultiPolygon" > }, > "properties": { > "cartodb_id": 1, > "created_at": "2013-11-12T16:15:59+0100", > "name": "Algeria", > "updated_at": "2013-11-12T16:15:59+0100", > "value": 1 custom > property > }, > "type": "Feature" > } > ], > "type": "FeatureCollection" > } > > > chris:tmp chris$ ogrinfo -summary -al africa.geojson > INFO: Open of `africa.geojson' > using driver `GeoJSON' successful. > > Layer name: africa > Geometry: Multi Polygon > Feature Count: 1 > Extent: (8.621624, 36.941797) - (8.621624, 36.941797) > Layer SRS WKT: > GEOGCS["WGS 84", > DATUM["WGS_1984", > SPHEROID["WGS 84",6378137,298.257223563, > AUTHORITY["EPSG","7030"]], > AUTHORITY["EPSG","6326"]], > PRIMEM["Greenwich",0, > AUTHORITY["EPSG","8901"]], > UNIT["degree",0.0174532925199433, > AUTHORITY["EPSG","9122"]], > AUTHORITY["EPSG","4326"]] > value: Integer (0.0) here’s the > additional > property > cartodb_id: Integer (0.0) > created_at: DateTime (0.0) > name: String (0.0) > updated_at: DateTime (0.0) > > > I haven't used geojson as a data source, but maybe if you shared a small > example of your map file and the data it would help. > > > > > -- > Sent from: http://osgeo-org.1560.x6.nabble.com/Mapserver-User- > f4226646.html > ___ > mapserver-users mailing list > mapserver-users@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/mapserver-users > -- Richard W. Greenwood, PLS www.greenwoodmap.com ___ mapserver-users mailing list mapserver-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Apply style to geojson based on property in geojson data
Hello Richard! > I haven't used geojson as a data source, but maybe if you shared a small > example of your map file and the data it would help. Here's some more information mapfile.map (excerpt): LAYER NAME "countries" STATUS OFF TYPE POLYGON CONNECTIONTYPE OGR CONNECTION "africa.geojson" DATA "select * from africa" CLASS STYLE OUTLINECOLOR "#ff" END END CLASS EXPRESSION ([value] >= 0 AND [value] <= 100) STYLE COLOR "#FFE397" END END END I have tried numerous types of select statement in the DATA definition, but have failed to influence the styling based on the ‘value’ property added to the geojson file. Of course, this may have all been in vain, if the GDAL driver does not support anything other than ‘select * from ’, but I cannot tell from the documentation - MapServer, or GDAL - what is allowed. Here is an excerpt of the africa.geojson file, with the additional property ‘value’ added. Following is the output from ogrinfo. { "features": [ { "geometry": { "coordinates": [ [ [ [ 8.621624, 36.941797 ], [ 8.621624, 36.941797 ] ] ] ], "type": "MultiPolygon" }, "properties": { "cartodb_id": 1, "created_at": "2013-11-12T16:15:59+0100", "name": "Algeria", "updated_at": "2013-11-12T16:15:59+0100", "value": 1 custom property }, "type": "Feature" } ], "type": "FeatureCollection" } chris:tmp chris$ ogrinfo -summary -al africa.geojson INFO: Open of `africa.geojson' using driver `GeoJSON' successful. Layer name: africa Geometry: Multi Polygon Feature Count: 1 Extent: (8.621624, 36.941797) - (8.621624, 36.941797) Layer SRS WKT: GEOGCS["WGS 84", DATUM["WGS_1984", SPHEROID["WGS 84",6378137,298.257223563, AUTHORITY["EPSG","7030"]], AUTHORITY["EPSG","6326"]], PRIMEM["Greenwich",0, AUTHORITY["EPSG","8901"]], UNIT["degree",0.0174532925199433, AUTHORITY["EPSG","9122"]], AUTHORITY["EPSG","4326"]] value: Integer (0.0) here’s the additional property cartodb_id: Integer (0.0) created_at: DateTime (0.0) name: String (0.0) updated_at: DateTime (0.0) I haven't used geojson as a data source, but maybe if you shared a small example of your map file and the data it would help. -- Sent from: http://osgeo-org.1560.x6.nabble.com/Mapserver-User-f4226646.html ___ mapserver-users mailing list mapserver-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/mapserver-users
Re: [mapserver-users] Apply style to geojson based on property in geojson data
I haven't used geojson as a data source, but maybe if you shared a small example of your map file and the data it would help. On Tue, Oct 24, 2017 at 8:43 AM, Tuffawrote: > Hello! > > I am rendering a map of African countries from a single geojson file. Each > country is represented as a feature with geometry. I've added a custom > value to each feature's properties, that I would like to influence the > style > selected by MapServer to render the country outline, however I cannot see > how it is possible to configure the layer so that MapServer uses the new > 'value' property as the input for the style expressions that I have > created... > > Doing the same job, using a database as the datasource is easy! I simply > craft a SQL 'select' statement for the mapfile's Layer 'DATA' to retrieve > the desired value and it becomes available to MapServer using the > '[value_name]' syntax in style expressions. > > This same approach does not appear to work for GeoJSON. MapServer states > that the extent of support for the 'DATA' is driver-dependant, which is > fair > enough; examination of the geoJson driver doc in the GDAL doc's does not > help me though. > > Can anyone help? > > Regards > Chris > > > > -- > Sent from: http://osgeo-org.1560.x6.nabble.com/Mapserver-User- > f4226646.html > ___ > mapserver-users mailing list > mapserver-users@lists.osgeo.org > https://lists.osgeo.org/mailman/listinfo/mapserver-users -- Richard W. Greenwood, PLS www.greenwoodmap.com ___ mapserver-users mailing list mapserver-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/mapserver-users
[mapserver-users] Apply style to geojson based on property in geojson data
Hello! I am rendering a map of African countries from a single geojson file. Each country is represented as a feature with geometry. I've added a custom value to each feature's properties, that I would like to influence the style selected by MapServer to render the country outline, however I cannot see how it is possible to configure the layer so that MapServer uses the new 'value' property as the input for the style expressions that I have created... Doing the same job, using a database as the datasource is easy! I simply craft a SQL 'select' statement for the mapfile's Layer 'DATA' to retrieve the desired value and it becomes available to MapServer using the '[value_name]' syntax in style expressions. This same approach does not appear to work for GeoJSON. MapServer states that the extent of support for the 'DATA' is driver-dependant, which is fair enough; examination of the geoJson driver doc in the GDAL doc's does not help me though. Can anyone help? Regards Chris -- Sent from: http://osgeo-org.1560.x6.nabble.com/Mapserver-User-f4226646.html ___ mapserver-users mailing list mapserver-users@lists.osgeo.org https://lists.osgeo.org/mailman/listinfo/mapserver-users