mil.nga.sf.geojson.Position.additionalElements: lost additional when FeatureConverter.toStringValue()
alx696 opened this issue · 3 comments
Please fill out as much known and relevant information as possible.
Version Information:
- SF GeoJSON Java Version: mil.nga.sf:sf-geojson:2.0.4
- SF GeoJSON Java Source: Central Repository
- IDE Name & Version: Android Studio
- Maven Version: Gradle
- Java Version: 8
- Platform & OS: Android 10
- Other Relevant Libraries: -
Expected Results:
- What did you expect to happen?
two additional element after FeatureConverter.toStringValue().
Observed Results:
-
What happened instead?
only one additional element. -
How often does this occur?
List<Position> pointList = new ArrayList<>();
for (DbTrackPoint tp : t.getPoints()) {
pointList.add(
new Position(
tp.getLon(), tp.getLat(), tp.getAlt(),
1d,
2d
)
);
}
LineString line = new LineString();
line.setCoordinates(pointList);
Map<String, Object> propertyMap = new LinkedHashMap<>();
propertyMap.put("source", SOURCE);
Feature lineFeature = new Feature(line);
lineFeature.setProperties(propertyMap);
featureCollection.addFeature(lineFeature);
FileUtils.writeStringToFile(
file,
FeatureConverter.toStringValue(featureCollection),
"UTF-8"
);
But 2
lost, only 1
keep:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
114.41760627,
30.47035912,
14.82720947265625,
1.0
],
[
114.41777497,
30.47037775,
17.23809814453125,
1.0
]
...
Additional Information:
Can i add more than one additionalElements? Why only one?
Simple Features only supports a x, y, z, and m value. GeoJSON supports additional elements. The Simple Features GeoJSON library LineString currently re-uses the Simple Features library LineString and is causing that loss. We'll have to see if we can change the GeoJSON LineString implementation to preserve those.
@bosborn Thanks for your answer! It is better to add a comment, let us know the limit.
Fixed in version 3.0.0. As long as the GeoJSON objects are not converted to base simple features, additional elements are now preserved.