[mapserver-users] Apply style to geojson based on property in geojson data
Richard Greenwood
richard.greenwood at gmail.com
Wed Oct 25 08:09:53 PDT 2017
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, Tuffa <chris at wherryengineering.co.uk>
wrote:
> 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 "#ff0000" END END
> CLASS EXPRESSION ([value] >= 0 AND [value] <= 1000000) 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 <layer>’, 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": 10000 <<<<<<<<<<<<<<<<<<<<<<<<<<<< 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 at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/mapserver-users
>
--
Richard W. Greenwood, PLS
www.greenwoodmap.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/mapserver-users/attachments/20171025/e5095761/attachment.htm>
More information about the MapServer-users
mailing list