I have an object I am trying to save with the Key-Value Store but it fails serialization, I think this is due to it containing a bounding box , (being a list of doubles (lat,lng, lat lng))
The project also contains other classes with lists of coordinates which I am looking to save ,so Im looking for a solution that allows me persistence whilst maintaining the structure of the class
The project also contains other classes with lists of coordinates which I am looking to save ,so Im looking for a solution that allows me persistence whilst maintaining the structure of the class
B4X:
'Object is of type "GeocodedLocation"
Sub Class_Globals
Dim id As String
Dim gid As String
Dim layer As String
Dim source As String
Dim source_id As String
Dim name As String
Dim housenumber As String
Dim street As String
Dim confidence As Int
Dim match_type As String
Dim distance As Int
Dim accuracy As String
Dim country As String
Dim country_gid As String
Dim country_a As String
Dim region As String
Dim region_gid As String
Dim region_a As String
Dim county As String
Dim county_gid As String
Dim county_a As String
Dim locality As String
Dim locality_gid As String
Dim continent As String
Dim continent_gid As String
Dim label As String
Dim Latitude As Double
Dim Longitude As Double
Dim height As Int
Dim BoundingBox As List ' ( this is a list of 4 doubles, lat,lng,lat,lng)
Dim requiresGeocoding As Boolean
End Sub
' here I am simply saving the object
Sub saveLocation ( tag As String, l As geocodedLocation)
Starter.kvs.Put(tag,l)
End Sub
'LOG
job
{"geocoding":{"version":"0.2","attribution":"openrouteservice.org | OpenStreetMap contributors | Geocoding by Pelias","query":{"text":"200 Victoria Street Hamilton New Zealand","size":10,"private":false,"lang":{"name":"English","iso6391":"en","iso6393":"eng","defaulted":true},"querySize":20,"parser":"libpostal","parsed_text":{"number":"200","street":"victoria street","city":"hamilton","country":"new zealand"}},"engine":{"name":"Pelias","author":"Mapzen","version":"1.0"},"timestamp":1562742913764},"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":[175.266497,-37.771428]},"properties":{"id":"102079271","gid":"whosonfirst:county:102079271","layer":"county","source":"whosonfirst","source_id":"102079271","name":"Hamilton City","confidence":0.4,"match_type":"fallback","accuracy":"centroid","country":"New Zealand","country_gid":"whosonfirst:country:85633345","country_a":"NZL","region":"Waikato Region","region_gid":"whosonfirst:region:85687229","region_a":"WK","county":"Hamilton City","county_gid":"whosonfirst:county:102079271","county_a":"HM","continent":"Oceania","continent_gid":"whosonfirst:continent:102191583","label":"Hamilton City, New Zealand"},"bbox":[175.1843005,-37.846039184,175.344869484,-37.6993298504]},{"type":"Feature","geometry":{"type":"Point","coordinates":[175.289863,-37.765649]},"properties":{"id":"101914271","gid":"whosonfirst:locality:101914271","layer":"locality","source":"whosonfirst","source_id":"101914271","name":"Hamilton","confidence":0.6,"match_type":"fallback","accuracy":"centroid","country":"New Zealand","country_gid":"whosonfirst:country:85633345","country_a":"NZL","region":"Waikato Region","region_gid":"whosonfirst:region:85687229","region_a":"WK","county":"Hamilton City","county_gid":"whosonfirst:county:102079271","county_a":"HM","locality":"Hamilton","locality_gid":"whosonfirst:locality:101914271","continent":"Oceania","continent_gid":"whosonfirst:continent:102191583","label":"Hamilton, New Zealand"},"bbox":[175.218250114,-37.8318706255,175.33390517,-37.723626726]}],"bbox":[175.1843005,-37.846039184,175.344869484,-37.6993298504]}
Origin SUCCESFULLY SET = Hamilton City, New Zealand
Error occurred on line: 220 (directionsAndGeocoding)
java.lang.RuntimeException: Cannot serialize object: [accuracy=centroid, appoptions=null, boundingbox=(ArrayList) [175.1843005, -37.846039184, 175.344869484, -37.6993298504]
, confidence=0, continent=Oceania, continent_gid=whosonfirst:continent:102191583
, country=New Zealand, country_a=NZL, country_gid=whosonfirst:country:85633345
, county=Hamilton City, county_a=HM, county_gid=whosonfirst:county:102079271
, distance=0, getdirections=null, gid=102079271
, height=0, housenumber=null, httputils2service=null
, id=whosonfirst:county:102079271, label=Hamilton City, New Zealand, latitude=-37.771428
, layer=county, locality=null, locality_gid=null
, longitude=175.266497, main=null, makenote=null
, match_type=, name=Hamilton City, pra=null
, region=Waikato Region, region_a=WK, region_gid=whosonfirst:region:85687229
, requiresgeocoding=false, routeprep=null, source=whosonfirst
, source_id=102079271, starter=null, street=null
]
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeType(B4XSerializator.java:258)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeObject(B4XSerializator.java:224)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeList(B4XSerializator.java:252)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.writeObject(B4XSerializator.java:204)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.WriteObject(B4XSerializator.java:104)
at anywheresoftware.b4a.randomaccessfile.B4XSerializator.ConvertObjectToBytes(B4XSerializator.java:62)
at b4a.example3.keyvaluestore._put(keyvaluestore.java:395)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
at com.ideas.openroad.directionsandgeocoding._savelocation(directionsandgeocoding.java:817)
at com.ideas.openroad.directionsandgeocoding._processreturn(directionsandgeocoding.java:523)
at com.ideas.openroad.directionsandgeocoding$ResumableSub_LatLngFromAddress.resume(directionsandgeocoding.java:783)
at anywheresoftware.b4a.shell.DebugResumableSub$DelegatableResumableSub.resumeAsUserSub(DebugResumableSub.java:48)
at java.lang.reflect.Method.invoke(Native Method)