abhinav-adtechs / osmbonuspack

Automatically exported from code.google.com/p/osmbonuspack
0 stars 0 forks source link

UnsupportedOperationException when GeoJSON contains nested properties #111

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Try to parse geojson with nested "properties" section like
{"features":[{"geometry":{"coordinates":[36.8, 
55.9],"type":"Point"},"properties":{"address":"Ставропольская 
улица, дом 37, корпус 
1","id":1,"layer":2,"name":"Психоневрологический 
интернат № 11"},"type":"Feature"},{"geometry":{"coordinates":[37.8, 
56.9],"type":"Point"},"properties":{"count":4,"extent":{"bottom":1,"left":2,"rig
ht":3,"top":4},"layer":-1,"objects":{"0":{"count":4,"id":1,"layer":2}}},"type":"
Feature"}],"type":"FeatureCollection"}

What is the expected output? What do you see instead?
Parsing excepted.
Actualy UnsupportedOperationException throwed in KmlPlacemark line 97
String value = entry.getValue().getAsString();

What version of the products are you using (Android SDK, osmdroid,
OSMBonusPack)?
    compile 'org.osmdroid:osmdroid-android:4.2'
    compile 'org.slf4j:slf4j-simple:1.6.1'
    compile 'com.google.code.gson:gson:2.3';
    compile 'org.apache.commons:commons-lang3:3.3.2';
OSMBonusPack - 5.1

Please provide any additional information below.

Original issue reported on code.google.com by DmitryIl...@gmail.com on 9 Feb 2015 at 6:38

GoogleCodeExporter commented 8 years ago
Effectively, properties values which are not String are not supported, as 
stated in https://code.google.com/p/osmbonuspack/wiki/GeoJSON

For nested properties, would you like to have the whole value converted as a 
String? 
In your extent exemple, a String containing this:
{"bottom":1,"left":2,"right":3,"top":4}

Original comment by mathieu....@gmail.com on 9 Feb 2015 at 1:53

GoogleCodeExporter commented 8 years ago
I think if I get String I have to wrap it in JsonElement again to parse and 
extract data, so it is a little redundant. It's better to have method returned 
nested properties as JsonElement.

Original comment by DmitryIl...@gmail.com on 9 Feb 2015 at 2:01

GoogleCodeExporter commented 8 years ago
Not so simple: those properties are stored in KML Placemark Extended Data. 
Which are not coming from JSON but from XML. 
Convert nested properties as a String is the best I can reasonably do. 

Original comment by mathieu....@gmail.com on 10 Feb 2015 at 10:53

GoogleCodeExporter commented 8 years ago
Code change just commited, with solution as described above. 
Not ideal, but better than a global parsing exception. 

Original comment by mathieu....@gmail.com on 21 Feb 2015 at 5:10