GeoSpatial Service

This module offers a complete set of APIs for GeoSpatial Services on cloud including storage, retrieval, query and updation of geographical data. You can store geographical data with unique handler on the cloud and search, update and query on the same. The query includes locating nearby/in-circle target points from given location using Geo points stored on the cloud.

In order to use the various functions available in a specific API, the developer has to initialize with App42API by passing the apiKey and the secretKey which will become available after the app creation from AppHQ dashboard.

Required Parameters

apiKey - The Application key given when the application was created.
secretKey - The secret key corresponding to the application key given when the application was created.

After initialization, the developer will have to call the buildXXXService method on App42API to get the instance of the particular API that they wish to build. For example, to build an instance of GeoService, buildGeoService() method needs to be called.

GeoService geoService = App42API.buildGeoService();

GeoService *geoService = [App42API buildGeoService];

let geoService = App42API.buildGeoService as! GeoService

GeoService geoService = App42API.buildGeoService();

GeoService geoService = App42API.BuildGeoService();

var geoService = new App42Geo();

local geoService = App42API:buildGeoService()

GeoService *geoService = App42API::BuildGeoService();

GeoService geoService = App42API.BuildGeoService();

$geoService = App42API::buildGeoService();

Coming Soon

geo_service = api.build_geo_service()

var geoService:GeoService = App42API.buildGeoService();

Coming Soon

GeoService geoService = App42API.buildGeoService();

Create Geo Points

Stores the Geo points with unique handler on the cloud. Geo point data contains lat, lng and marker of the point.

local storageName = "<Your_storage_name>";
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local geoService = App42API:buildGeoService()
geoService:getAllStorage(App42CallBack)
function App42CallBack:onSuccess(object)
if table.getn(object) >1 then
for m=1,table.getn(object) do
print("Storage Name is "..object[m]:getStorageName())
print("CreateOn is "..object[m]:getCreatedOn())
end
else
print("Storage Name is "..object:getStorageName())
print("CreateOn is "..object:getCreatedOn())
end
end
function App42CallBack:onException(exception)
print("Message is : "..exception:getMessage())
print("App Error code is : "..exception:getAppErrorCode())
print("Http Error code is "..exception:getHttpErrorCode())
print("Detail is : "..exception:getDetails())
end

local storageName = "<Your_storage_name>";
local max = 1;
local offset = 0;
local App42CallBack = {}
App42API:initialize("API_KEY","SECRET_KEY")
local geoService = App42API:buildGeoService()
geoService:getAllStorageByPaging(max,offset,App42CallBack)
function App42CallBack:onSuccess(object)
if table.getn(object) >1 then
for m=1,table.getn(object) do
print("Storage Name is "..object[m]:getStorageName())
print("CreateOn is "..object[m]:getCreatedOn())
end
else
print("Storage Name is "..object:getStorageName())
print("CreateOn is "..object:getCreatedOn())
end
end
function App42CallBack:onException(exception)
print("Message is : "..exception:getMessage())
print("App Error code is : "..exception:getAppErrorCode())
print("Http Error code is "..exception:getHttpErrorCode())
print("Detail is : "..exception:getDetails())
end

The functions available under Geo Spatial API can throw some exceptions in abnormal conditions. For example, if a developer is trying to delete the storage that does not exist, the function will throw the App42Exception (as shown below) with message as “Not Found” and the appErrorCode as “2903” and the details as “No Geo Storage exists with name ‘@storageName’”.

Functions in Message API might throw exceptions with following HTTP and Application Error Codes (along with their descriptions):

1400 - BAD REQUEST - The Request parameters are invalid.
1401 - UNAUTHORIZED - Client is not authorized.
1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again.
2900 - NOT FOUND - No destination found using given parameter Lat : '@lat' Long : '@lng' and Distance In KM '@distanceInKM'.
2901 - NOT FOUND - No destination found using given parameter Lat : '@lat' Long : '@lng' and Radius In KM '@radiusInKM'.
2902 - NOT FOUND - No Geo Storage exists.
2903 - NOT FOUND - No Geo Storage exists with name '@storageName'.
2904 - NOT FOUND - No Geo Points in the storage '@storageName' exist.
2905 - NOT FOUND - No destination found using given parameter Lat : '@lat' Long : '@lng'.
2906 - NOT FOUND - The number of Storage is less than the specified offset.
2907 - NOT FOUND - No Geo Point found using given parameter Marker: '@marker' Lat : '@lat' Long : '@lng'.