2

A record is successfully inserted using this query:

INSERT INTO test.geoPSGC (PK,PSGC,NAME,COORDINATES) VALUES ("PH042103059","PH042103059","P.F. ESPIRITU VIII", GEOJSON('{"type": "Polygon", "coordinates": [[[120.963819085,14.4360609570001],[120.963508642,14.437767122],[120.963132639,14.4396434060001],[120.963030111,14.4401597790001],[120.962205408,14.4399052410001],[120.960393097,14.439447073],[120.960260737,14.4401495980001],[120.96018129,14.440132872],[120.959486942,14.439986693],[120.959097233,14.4411254360001],[120.959038955,14.441300109],[120.960790176,14.441788822],[120.960572028,14.4424181910001],[120.959700188,14.4445419810001],[120.960098399,14.4447199690001],[120.960774416,14.4450736870001],[120.960692088,14.4452229070001],[120.960470831,14.4456654210001],[120.960321611,14.445969007],[120.958550232,14.4448707610001],[120.958129094,14.443015749],[120.955905609,14.4426806610001],[120.955608883,14.443570838],[120.955346395,14.4434795380001],[120.955289332,14.4437420260001],[120.954969781,14.443696376],[120.954889894,14.4440045150001],[120.954225114,14.443719201],[120.953954066,14.443696376],[120.952336035,14.444176962],[120.952255088,14.443998277],[120.953521745,14.443688057],[120.953902021,14.4424971950001],[120.954722615,14.442737369],[120.954912753,14.4421769630001],[120.955873449,14.442287043],[120.956533927,14.440325622],[120.956223702,14.440255571],[120.95590347,14.440245564],[120.955142919,14.4402956],[120.954782659,14.440255571],[120.954332332,14.4400954550001],[120.954452419,14.439054701],[120.953801948,14.438904592],[120.952911303,14.438774498],[120.952965697,14.438500543],[120.952985959,14.4382396770001],[120.953011179,14.4381358630001],[120.953277921,14.4369847450001],[120.953318707,14.4368087330001],[120.956736645,14.436828264],[120.956768379,14.4362091220001],[120.956779247,14.435895783],[120.956804391,14.4355445270001],[120.956772893,14.435371087],[120.956809539,14.4351651270001],[120.956836543,14.434532458],[120.956863741,14.4340464310001],[120.956467101,14.4338641910001],[120.9557208,14.4338163350001],[120.955738353,14.4330264620001],[120.955744235,14.4323139710001],[120.957669155,14.4323067990001],[120.957844682,14.4326051960001],[120.96010627,14.4329594650001],[120.961732768,14.4327991060001],[120.962557471,14.4326845640001],[120.964088989,14.4329410820001],[120.96407482,14.433125068],[120.964044954,14.433513331],[120.964071138,14.433868956],[120.964138908,14.434272455],[120.964139531,14.4343794550001],[120.963928361,14.435506225],[120.963819085,14.4360609570001]]]}'));

But throwing an error "Unrecognized token 'GEOJSON' when using Aerospike Rest Client v1.10.4 (latest)

Request body:

{
    "PSGC": "PH042103059",
    "NAME": "P.F. ESPIRITU VIII",
    "COORDINATES": GEOJSON('{"type": "Polygon", "coordinates": [[[120.963819085,14.4360609570001],[120.963508642,14.437767122],[120.963132639,14.4396434060001],[120.963030111,14.4401597790001],[120.962205408,14.4399052410001],[120.960393097,14.439447073],[120.960260737,14.4401495980001],[120.96018129,14.440132872],[120.959486942,14.439986693],[120.959097233,14.4411254360001],[120.959038955,14.441300109],[120.960790176,14.441788822],[120.960572028,14.4424181910001],[120.959700188,14.4445419810001],[120.960098399,14.4447199690001],[120.960774416,14.4450736870001],[120.960692088,14.4452229070001],[120.960470831,14.4456654210001],[120.960321611,14.445969007],[120.958550232,14.4448707610001],[120.958129094,14.443015749],[120.955905609,14.4426806610001],[120.955608883,14.443570838],[120.955346395,14.4434795380001],[120.955289332,14.4437420260001],[120.954969781,14.443696376],[120.954889894,14.4440045150001],[120.954225114,14.443719201],[120.953954066,14.443696376],[120.952336035,14.444176962],[120.952255088,14.443998277],[120.953521745,14.443688057],[120.953902021,14.4424971950001],[120.954722615,14.442737369],[120.954912753,14.4421769630001],[120.955873449,14.442287043],[120.956533927,14.440325622],[120.956223702,14.440255571],[120.95590347,14.440245564],[120.955142919,14.4402956],[120.954782659,14.440255571],[120.954332332,14.4400954550001],[120.954452419,14.439054701],[120.953801948,14.438904592],[120.952911303,14.438774498],[120.952965697,14.438500543],[120.952985959,14.4382396770001],[120.953011179,14.4381358630001],[120.953277921,14.4369847450001],[120.953318707,14.4368087330001],[120.956736645,14.436828264],[120.956768379,14.4362091220001],[120.956779247,14.435895783],[120.956804391,14.4355445270001],[120.956772893,14.435371087],[120.956809539,14.4351651270001],[120.956836543,14.434532458],[120.956863741,14.4340464310001],[120.956467101,14.4338641910001],[120.9557208,14.4338163350001],[120.955738353,14.4330264620001],[120.955744235,14.4323139710001],[120.957669155,14.4323067990001],[120.957844682,14.4326051960001],[120.96010627,14.4329594650001],[120.961732768,14.4327991060001],[120.962557471,14.4326845640001],[120.964088989,14.4329410820001],[120.96407482,14.433125068],[120.964044954,14.433513331],[120.964071138,14.433868956],[120.964138908,14.434272455],[120.964139531,14.4343794550001],[120.963928361,14.435506225],[120.963819085,14.4360609570001]]]}'))
}
Don
  • 163
  • 12

2 Answers2

5

Try to use the following structure:

{
  "PSGC": "PH042103059",
  "NAME": "P.F. ESPIRITU VIII",
  "COORDINATES": {
    "type": "GEO_JSON",
    "value": Base64(geo_json_string)
  }
}

Also, this can be done using MessagePack.

reugn
  • 166
  • 3
  • It worked. it that the long term approach on creating GEO_JSON using rest client? or there is an ongoing enhancement for that? – Don Feb 02 '22 at 09:04
  • It was successfully inserted using rest client but not working as GeoJSON. This query below only returns a record when using insert query. ``` SELECT * FROM test.geoPSGC WHERE COORDINATES CONTAINS GeoJSON('{"type":"Point","coordinates":[120.9559,14.44024]}') ``` – Don Feb 02 '22 at 22:41
  • It is now working by removing the escape character for double quotes before converting to base64. – Don Feb 03 '22 at 20:16
  • @Don, REST-Gateway 2.0.1 added an enhancement for create geo_json. Please see my answer below – JDogMcSteezy Aug 31 '23 at 18:33
2

In the rest-client 2.0.1 (now known as REST Gateway) you can now send a GeoJSON bin in the following form:

{
    "PSGC": "PH042103059",
    "NAME": "P.F. ESPIRITU VIII",
    "COORDINATES": 
       {
           "type": "Polygon", 
           "coordinates": [[[120.963819085,14.4360609570001],[120.963508642,14.437767122],[120.963132639,14.4396434060001],[120.963030111,14.4401597790001],[120.962205408,14.4399052410001],[120.960393097,14.439447073],[120.960260737,14.4401495980001],[120.96018129,14.440132872],[120.959486942,14.439986693],[120.959097233,14.4411254360001],[120.959038955,14.441300109],[120.960790176,14.441788822],[120.960572028,14.4424181910001],[120.959700188,14.4445419810001],[120.960098399,14.4447199690001],[120.960774416,14.4450736870001],[120.960692088,14.4452229070001],[120.960470831,14.4456654210001],[120.960321611,14.445969007],[120.958550232,14.4448707610001],[120.958129094,14.443015749],[120.955905609,14.4426806610001],[120.955608883,14.443570838],[120.955346395,14.4434795380001],[120.955289332,14.4437420260001],[120.954969781,14.443696376],[120.954889894,14.4440045150001],[120.954225114,14.443719201],[120.953954066,14.443696376],[120.952336035,14.444176962],[120.952255088,14.443998277],[120.953521745,14.443688057],[120.953902021,14.4424971950001],[120.954722615,14.442737369],[120.954912753,14.4421769630001],[120.955873449,14.442287043],[120.956533927,14.440325622],[120.956223702,14.440255571],[120.95590347,14.440245564],[120.955142919,14.4402956],[120.954782659,14.440255571],[120.954332332,14.4400954550001],[120.954452419,14.439054701],[120.953801948,14.438904592],[120.952911303,14.438774498],[120.952965697,14.438500543],[120.952985959,14.4382396770001],[120.953011179,14.4381358630001],[120.953277921,14.4369847450001],[120.953318707,14.4368087330001],[120.956736645,14.436828264],[120.956768379,14.4362091220001],[120.956779247,14.435895783],[120.956804391,14.4355445270001],[120.956772893,14.435371087],[120.956809539,14.4351651270001],[120.956836543,14.434532458],[120.956863741,14.4340464310001],[120.956467101,14.4338641910001],[120.9557208,14.4338163350001],[120.955738353,14.4330264620001],[120.955744235,14.4323139710001],[120.957669155,14.4323067990001],[120.957844682,14.4326051960001],[120.96010627,14.4329594650001],[120.961732768,14.4327991060001],[120.962557471,14.4326845640001],[120.964088989,14.4329410820001],[120.96407482,14.433125068],[120.964044954,14.433513331],[120.964071138,14.433868956],[120.964138908,14.434272455],[120.964139531,14.4343794550001],[120.963928361,14.435506225],[120.963819085,14.4360609570001]]]
       }
}

More information on geojson, byte-arrays, and using msgpack can be found here

For example, here is a snippet writing a geojson bin using msgpack in java:

MessageBufferPacker packer=new MessagePack.PackerConfig().newBufferPacker();
        String geoString="{\"coordinates\": [-122.0, 37.5], \"type\": \"Point\"}";
        packer.packMapHeader(1);
        packer.packString("geo_bin");
        packer.packExtensionTypeHeader((byte)23,geoString.length());
        packer.addPayload(geoString.getBytes("UTF-8"));
JDogMcSteezy
  • 260
  • 2
  • 7