Revision: 5188 http://sourceforge.net/p/jump-pilot/code/5188 Author: edso Date: 2016-11-15 10:02:05 +0000 (Tue, 15 Nov 2016) Log Message: ----------- GeoJSON spec expects properties object to written all the time, might be null though
Modified Paths: -------------- core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONConstants.java core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONFeatureCollectionWrapper.java Modified: core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONConstants.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONConstants.java 2016-11-14 07:46:15 UTC (rev 5187) +++ core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONConstants.java 2016-11-15 10:02:05 UTC (rev 5188) @@ -2,14 +2,17 @@ public class GeoJSONConstants { public static final String CHARSET = "UTF-8"; - + public static final String PROPERTIES = "properties"; public static final String GEOMETRY = "geometry"; public static final String FEATURES = "features"; public static final String TYPE = "type"; - + public static final String TYPE_FEATURE = "Feature"; public static final String TYPE_FEATURECOLLECTION = "FeatureCollection"; - - public static final String EMPTY_GEOMETRY = "\"geometry\": {\"type\":\"GeometryCollection\",\"geometries\":[]}"; + + // for performance reasons, prevent concatenating the same string + public static final String EMPTY_GEOMETRY = "\"" + GEOMETRY + + "\": {\"type\":\"GeometryCollection\",\"geometries\":[]}"; + public static final String EMPTY_PROPERTIES = "\"" + PROPERTIES + "\" : null"; } Modified: core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONFeatureCollectionWrapper.java =================================================================== --- core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONFeatureCollectionWrapper.java 2016-11-14 07:46:15 UTC (rev 5187) +++ core/trunk/src/com/vividsolutions/jump/io/geojson/GeoJSONFeatureCollectionWrapper.java 2016-11-15 10:02:05 UTC (rev 5188) @@ -319,13 +319,16 @@ else geometryJson = GeoJSONConstants.EMPTY_GEOMETRY; + // the GeoJSON specs expect properties to be written, it might be null when empty if (propertiesJson != null) propertiesJson = "\"" + GeoJSONConstants.PROPERTIES + "\": { " + propertiesJson + " }"; + else + propertiesJson = GeoJSONConstants.EMPTY_PROPERTIES; return "{ \"" + GeoJSONConstants.TYPE + "\": \"" + GeoJSONConstants.TYPE_FEATURE + "\"" - + (propertiesJson != null ? ", " + propertiesJson : "") - + (geometryJson != null ? ", " + geometryJson : "") + " }"; + + ", " + propertiesJson + + ", " + geometryJson; } } ------------------------------------------------------------------------------ _______________________________________________ Jump-pilot-devel mailing list Jump-pilot-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel