Spatial Data Create/Update API¶
Backendless SDK includes special classes which facilitate saving of spatial data values in the database. The same classes are used to represent spatial data when it is retrieved from the database. For more information about data retrieval, see the Spatial Data Retrieval API section.
POINT Values¶
Consider the following table schema in Backendless database. Notice the pickupLocation
and the dropoffLocation
columns. Both are of type POINT
:
The following code demonstrates how to create a new object with POINT
properties in the Order
table:
Order class:
public class Order
{
private Point pickupLocation;
private Point dropoffLocation;
private String orderName;
private String objectId;
public String getObjectId()
{
return objectId;
}
public void setObjectId( String objectId )
{
this.objectId = objectId;
}
public Point getPickupLocation()
{
return pickupLocation;
}
public void setPickupLocation( Point pickupLocation )
{
this.pickupLocation = pickupLocation;
}
public Point getDropoffLocation()
{
return dropoffLocation;
}
public void setDropoffLocation( Point dropoffLocation )
{
this.dropoffLocation = dropoffLocation;
}
public String getOrderName()
{
return orderName;
}
public void setOrderName( String orderName )
{
this.orderName = orderName;
}
}
Order myOrder = new Order();
myOrder.setOrderName( "Fun times" );
myOrder.setPickupLocation( new Point().setLatitude( 55.782309 ).setLongitude( 37.578639 ) );
myOrder.setDropoffLocation( new Point().setLatitude( 55.752917 ).setLongitude( 37.618900 ) );
Backendless.Data.of( Order.class ).save( myOrder, new AsyncCallback<Order>()
{
@Override
public void handleResponse( Order savedOrder )
{
String objectId = savedOrder.getObjectId();
}
@Override
public void handleFault( BackendlessFault fault )
{
}
});
Order class:
class Order {
var pickupLocation: Point? = null
var dropoffLocation: Point? = null
var orderName: String? = null
var objectId: String? = null
}
val myOrder = Order()
myOrder.orderName = "Fun times"
myOrder.pickupLocation = Point().setLatitude(55.782309).setLongitude(37.578639)
myOrder.dropoffLocation = Point().setLatitude(55.752917).setLongitude(37.618900)
Backendless.Data.of(Order::class.java).save(myOrder, object : AsyncCallback<Order> {
override fun handleResponse(savedOrder: Order) {
val objectId = savedOrder.objectId
}
override fun handleFault(fault: BackendlessFault) {
}
})
HashMap<String, Object> order = new HashMap<>( );
order.put( "orderName", "Fun times" );
order.put( "pickupLocation", new Point().setLatitude( 55.782309 ).setLongitude( 37.578639 ) );
order.put( "dropoffLocation", new Point().setLatitude( 55.752917 ).setLongitude( 37.618900 ) );
Backendless.Data.of( "Order" ).save( order, new AsyncCallback<Map>()
{
@Override
public void handleResponse( Map savedOrder )
{
String objectId = (String) savedOrder.get( "objectId" );
}
@Override
public void handleFault( BackendlessFault fault )
{
}
});
val order = HashMap<String, Any>()
order.put("orderName", "Fun times")
order.put("pickupLocation", Point().setLatitude(55.782309).setLongitude(37.578639))
order.put("dropoffLocation", Point().setLatitude(55.752917).setLongitude(37.618900))
Backendless.Data.of("Order").save(order, object : AsyncCallback<Map<Any?, Any?>> {
override fun handleResponse(savedOrder: Map<Any?, Any?>) {
val objectId = savedOrder["objectId"] as String?
}
override fun handleFault(fault: BackendlessFault) {
}
})
Codeless Reference
The example below creates a new object containing two GeoJSON (Point
) objects and saves it to the database called Order
:
where:
Argument | Description |
---|---|
table name |
Name of the data table where a new record must be saved. |
object |
An object to save in the database. Object properties must match the names of the table columns. The object must not have the objectId property. |
return result |
Optional parameter. When this box is checked, the operation returns the saved object with the objectId property. |
When you run the code(or Codeless logic), you will see the following in the database:
LINESTRING Values¶
Creating objects with LINESTRING
properties works similarly to the example shown above - your code needs to use corresponding class from the SDK. For example, the code below creates an object in the Travel
table with a LINESTRING
route:
Travel class:
public class Travel
{
private String name;
private LineString route;
private String objectId;
public String getName()
{
return name;
}
public void setName( String name )
{
this.name = name;
}
public LineString getRoute()
{
return route;
}
public void setRoute( LineString route )
{
this.route = route;
}
public String getObjectId()
{
return objectId;
}
public void setObjectId( String objectId )
{
this.objectId = objectId;
}
}
String route66LineString = "LINESTRING (-87.52683788 41.85716752, " +
"-90.13875858 38.68967135," +
" -95.93953983 36.2131248, " +
"-97.49959842 35.53656483, " +
"-101.8282117 35.26791494, " +
"-105.87118045 35.72083154, " +
"-106.61825076 35.14794417, " +
"-111.63900272 35.20182535, " +
"-118.24178592 34.07195769)";
LineString path = LineString.fromWKT( route66LineString );
Travel travelObject = new Travel();
travelObject.setName( "Route 66" );
travelObject.setRoute( path );
Backendless.Data.of( Travel.class ).save( travelObject, new AsyncCallback<Travel>()
{
@Override
public void handleResponse( Travel savedObject )
{
String objectId = savedObject.getObjectId();
}
@Override
public void handleFault( BackendlessFault fault )
{
}
} );
Travel class:
class Travel {
var name: String? = null
var route: LineString? = null
var objectId: String? = null
}
val route66LineString = "LINESTRING (-87.52683788 41.85716752, " +
"-90.13875858 38.68967135," +
" -95.93953983 36.2131248, " +
"-97.49959842 35.53656483, " +
"-101.8282117 35.26791494, " +
"-105.87118045 35.72083154, " +
"-106.61825076 35.14794417, " +
"-111.63900272 35.20182535, " +
"-118.24178592 34.07195769)"
val path = LineString.fromWKT<LineString>(route66LineString)
val travelObject = Travel()
travelObject.name = "Route 66"
travelObject.route = path
Backendless.Data.of(Travel::class.java).save(travelObject, object : AsyncCallback<Travel> {
override fun handleResponse(savedObject: Travel) {
val objectId = savedObject.objectId
}
override fun handleFault(fault: BackendlessFault) {
}
})
String route66LineString = "LINESTRING (-87.52683788 41.85716752, " +
"-90.13875858 38.68967135," +
" -95.93953983 36.2131248, " +
"-97.49959842 35.53656483, " +
"-101.8282117 35.26791494, " +
"-105.87118045 35.72083154, " +
"-106.61825076 35.14794417, " +
"-111.63900272 35.20182535, " +
"-118.24178592 34.07195769)";
LineString path = LineString.fromWKT( route66LineString );
HashMap<String, Object> travelObject = new HashMap<>();
travelObject.put( "name", "Route 66" );
travelObject.put( "route", path );
Backendless.Data.of( "Travel" ).save( travelObject, new AsyncCallback<Map>()
{
@Override
public void handleResponse( Map savedObject )
{
String objectId = (String) savedObject.get( "objectId" );
}
@Override
public void handleFault( BackendlessFault fault )
{
}
} );
val route66LineString = "LINESTRING (-87.52683788 41.85716752, " +
"-90.13875858 38.68967135," +
" -95.93953983 36.2131248, " +
"-97.49959842 35.53656483, " +
"-101.8282117 35.26791494, " +
"-105.87118045 35.72083154, " +
"-106.61825076 35.14794417, " +
"-111.63900272 35.20182535, " +
"-118.24178592 34.07195769)"
val path = LineString.fromWKT<LineString<*>>(route66LineString)
val travelObject = HashMap<String, Any>()
travelObject["name"] = "Route 66"
travelObject["route"] = path
Backendless.Data.of("Travel").save(travelObject, object : AsyncCallback<Map<Any?, Any?>> {
override fun handleResponse(savedObject: Map<Any?, Any?>) {
val objectId = savedObject["objectId"] as String?
}
override fun handleFault(fault: BackendlessFault) {
}
})
Notice the example above uses the LineString.fromWKT
method to convert a string representation of a geometry into an instance of the LineString
class. Alternatively, the code can use a constructor in the LineString
class which takes an collection of Point
objects. The example below and the one above produce exactly the same result using different approaches available in the SDK:
Travel class:
public class Travel
{
private String name;
private LineString route;
private String objectId;
public String getName()
{
return name;
}
public void setName( String name )
{
this.name = name;
}
public LineString getRoute()
{
return route;
}
public void setRoute( LineString route )
{
this.route = route;
}
public String getObjectId()
{
return objectId;
}
public void setObjectId( String objectId )
{
this.objectId = objectId;
}
}
Travel travelObject = new Travel();
travelObject.setName( "Route 66" );
List<Point> points = new ArrayList<>();
points.add( new Point().setLongitude( -90.13875858 ).setLatitude( 38.68967135 ) );
points.add( new Point().setLongitude( -95.93953983 ).setLatitude( 36.2131248 ) );
points.add( new Point().setLongitude( -97.49959842 ).setLatitude( 35.53656483 ) );
points.add( new Point().setLongitude( -101.8282117 ).setLatitude( 35.26791494 ) );
points.add( new Point().setLongitude( -105.87118045 ).setLatitude( 35.72083154 ) );
points.add( new Point().setLongitude( -106.61825076 ).setLatitude( 35.14794417 ) );
points.add( new Point().setLongitude( -111.63900272 ).setLatitude( 35.20182535 ) );
points.add( new Point().setLongitude( -118.24178592 ).setLatitude( 34.07195769 ) );
travelObject.setRoute( new LineString( points ) );
Backendless.Data.of( Travel.class ).save( travelObject, new AsyncCallback<Travel>()
{
@Override
public void handleResponse( Travel savedObject )
{
String objectId = savedObject.getObjectId();
}
@Override
public void handleFault( BackendlessFault fault )
{
}
} );
Travel class:
class Travel {
var name: String? = null
var route: LineString? = null
var objectId: String? = null
}
val travelObject = Travel()
travelObject.name = "Route 66"
val points = ArrayList<Point>()
points.add(Point().setLongitude(-90.13875858).setLatitude(38.68967135))
points.add(Point().setLongitude(-95.93953983).setLatitude(36.2131248))
points.add(Point().setLongitude(-97.49959842).setLatitude(35.53656483))
points.add(Point().setLongitude(-101.8282117).setLatitude(35.26791494))
points.add(Point().setLongitude(-105.87118045).setLatitude(35.72083154))
points.add(Point().setLongitude(-106.61825076).setLatitude(35.14794417))
points.add(Point().setLongitude(-111.63900272).setLatitude(35.20182535))
points.add(Point().setLongitude(-118.24178592).setLatitude(34.07195769))
travelObject.route = LineString<Point>(points)
Backendless.Data.of(Travel::class.java).save(travelObject, object : AsyncCallback<Travel> {
override fun handleResponse(savedObject: Travel) {
val objectId = savedObject.objectId
}
override fun handleFault(fault: BackendlessFault) {
}
})
HashMap<String, Object> travelObject = new HashMap<>();
travelObject.put( "name", "Route 66" );
List<Point> points = new ArrayList<>();
points.add( new Point().setLongitude( -90.13875858 ).setLatitude( 38.68967135 ) );
points.add( new Point().setLongitude( -95.93953983 ).setLatitude( 36.2131248 ) );
points.add( new Point().setLongitude( -97.49959842 ).setLatitude( 35.53656483 ) );
points.add( new Point().setLongitude( -101.8282117 ).setLatitude( 35.26791494 ) );
points.add( new Point().setLongitude( -105.87118045 ).setLatitude( 35.72083154 ) );
points.add( new Point().setLongitude( -106.61825076 ).setLatitude( 35.14794417 ) );
points.add( new Point().setLongitude( -111.63900272 ).setLatitude( 35.20182535 ) );
points.add( new Point().setLongitude( -118.24178592 ).setLatitude( 34.07195769 ) );
travelObject.put( "route", new LineString( points ) );
Backendless.Data.of( "Travel" ).save( travelObject, new AsyncCallback<Map>()
{
@Override
public void handleResponse( Map savedObject )
{
String objectId = (String) savedObject.get( "objectId" );
}
@Override
public void handleFault( BackendlessFault fault )
{
}
} );
val travelObject = HashMap<String, Any>()
travelObject.put("name", "Route 66")
val points = ArrayList<Point>()
points.add(Point().setLongitude(-90.13875858).setLatitude(38.68967135))
points.add(Point().setLongitude(-95.93953983).setLatitude(36.2131248))
points.add(Point().setLongitude(-97.49959842).setLatitude(35.53656483))
points.add(Point().setLongitude(-101.8282117).setLatitude(35.26791494))
points.add(Point().setLongitude(-105.87118045).setLatitude(35.72083154))
points.add(Point().setLongitude(-106.61825076).setLatitude(35.14794417))
points.add(Point().setLongitude(-111.63900272).setLatitude(35.20182535))
points.add(Point().setLongitude(-118.24178592).setLatitude(34.07195769))
travelObject.put("route", LineString(points))
Backendless.Data.of("Travel").save(travelObject, object : AsyncCallback<Map<Any?, Any?>> {
override fun handleResponse(savedObject: Map<Any?, Any?>) {
val objectId = savedObject["objectId"] as String?
}
override fun handleFault(fault: BackendlessFault) {
}
})
Codeless Reference
The example below creates a new object containing one GeoJSON (LineString
) object and saves it to the database called Travel
:
where:
Argument | Description |
---|---|
table name |
Name of the data table where a new record must be saved. |
object |
An object to save in the database. Object properties must match the names of the table columns. The object must not have the objectId property. |
return result |
Optional parameter. When this box is checked, the operation returns the saved object with the objectId property. |
When you run the code(or Codeless Logic), you will see the following object in the database:
POLYGON Values¶
Creating objects with properties of type POLYGON
can be done by using the com.backendless.persistence.Polygon
class. Consider the following example, it is a data table called Building
with a schema which includes a column named shape
of type POLYGON
:
The code below demonstrates how to create a new object with a POLYGON property in the database:
Building class:
import com.backendless.persistence.Polygon;
public class Building
{
private String name;
private Polygon shape;
private String objectId;
public String getName()
{
return name;
}
public void setName( String name )
{
this.name = name;
}
public Polygon getShape()
{
return shape;
}
public void setShape( Polygon shape )
{
this.shape = shape;
}
public String getObjectId()
{
return objectId;
}
public void setObjectId( String objectId )
{
this.objectId = objectId;
}
}
String pentagonPolygonString = "POLYGON (" +
"(-77.05786152 38.87261877, " +
"-77.0546978 38.87296123, " +
"-77.05317431 38.87061405, " +
"-77.0555883 38.86882611, " +
"-77.05847435 38.87002898, " +
"-77.05786152 38.87261877), " +
"(-77.05579215 38.87026286, " +
"-77.05491238 38.87087264, " +
"-77.05544882 38.87170794, " +
"-77.05669337 38.87156594, " +
"-77.05684357 38.87072228, " +
"-77.05579215 38.87026286))";
Polygon pentagonBuildingShape = Polygon.fromWKT( pentagonPolygonString );
Building buildingObject = new Building();
buildingObject.setName( "Pentagon" );
buildingObject.setShape( pentagonBuildingShape );
Backendless.Data.of( Building.class ).save( buildingObject, new AsyncCallback<Building>()
{
@Override
public void handleResponse( Building savedBuilding )
{
String objectId = savedBuilding.getObjectId();
}
@Override
public void handleFault( BackendlessFault fault )
{
}
} );
Building class:
import com.backendless.persistence.Polygon
class Building {
var name: String? = null
var shape: Polygon? = null
var objectId: String? = null
}
val pentagonPolygonString = "POLYGON (" +
"(-77.05786152 38.87261877, " +
"-77.0546978 38.87296123, " +
"-77.05317431 38.87061405, " +
"-77.0555883 38.86882611, " +
"-77.05847435 38.87002898, " +
"-77.05786152 38.87261877), " +
"(-77.05579215 38.87026286, " +
"-77.05491238 38.87087264, " +
"-77.05544882 38.87170794, " +
"-77.05669337 38.87156594, " +
"-77.05684357 38.87072228, " +
"-77.05579215 38.87026286))"
val pentagonBuildingShape = Polygon.fromWKT<Polygon>(pentagonPolygonString)
val buildingObject = Building()
buildingObject.name = "Pentagon"
buildingObject.shape = pentagonBuildingShape
Backendless.Data.of(Building::class.java).save(buildingObject, object : AsyncCallback<Building> {
override fun handleResponse(savedBuilding: Building) {
val objectId = savedBuilding.objectId
}
override fun handleFault(fault: BackendlessFault) {
}
})
String pentagonPolygonString = "POLYGON (" +
"(-77.05786152 38.87261877, " +
"-77.0546978 38.87296123, " +
"-77.05317431 38.87061405, " +
"-77.0555883 38.86882611, " +
"-77.05847435 38.87002898, " +
"-77.05786152 38.87261877), " +
"(-77.05579215 38.87026286, " +
"-77.05491238 38.87087264, " +
"-77.05544882 38.87170794, " +
"-77.05669337 38.87156594, " +
"-77.05684357 38.87072228, " +
"-77.05579215 38.87026286))";
Polygon pentagonBuildingShape = Polygon.fromWKT( pentagonPolygonString );
HashMap<String, Object> buildingObject = new HashMap<>();
buildingObject.put( "name", "Pentagon" );
buildingObject.put( "shape", pentagonBuildingShape );
Backendless.Data.of( "Building" ).save( buildingObject, new AsyncCallback<Map>()
{
@Override
public void handleResponse( Map savedBuilding )
{
String objectId = (String) savedBuilding.get( "objectId" );
}
@Override
public void handleFault( BackendlessFault fault )
{
}
} );
val pentagonPolygonString = "POLYGON (" +
"(-77.05786152 38.87261877, " +
"-77.0546978 38.87296123, " +
"-77.05317431 38.87061405, " +
"-77.0555883 38.86882611, " +
"-77.05847435 38.87002898, " +
"-77.05786152 38.87261877), " +
"(-77.05579215 38.87026286, " +
"-77.05491238 38.87087264, " +
"-77.05544882 38.87170794, " +
"-77.05669337 38.87156594, " +
"-77.05684357 38.87072228, " +
"-77.05579215 38.87026286))"
val pentagonBuildingShape = Polygon.fromWKT<Point>(pentagonPolygonString)
val buildingObject = HashMap<String, Any>()
buildingObject.put("name", "Pentagon")
buildingObject.put("shape", pentagonBuildingShape)
Backendless.Data.of("Building").save(buildingObject, object : AsyncCallback<Map<Any?, Any?>> {
override fun handleResponse(savedBuilding: Map<Any?, Any?>) {
val objectId = savedBuilding["objectId"] as String?
}
override fun handleFault(fault: BackendlessFault) {
}
})
Notice the example above uses the Polygon.fromWKT
method to convert a string representation of a geometry into an instance of the Polygon
class. Alternatively, the code can use a constructor in the Polygon
class which accepts two collections - the boundary points and the holes. The example below and the one above produce exactly the same result using different approaches available in the SDK:
Building class:
import com.backendless.persistence.Polygon;
public class Building
{
private String name;
private Polygon shape;
private String objectId;
public String getName()
{
return name;
}
public void setName( String name )
{
this.name = name;
}
public Polygon getShape()
{
return shape;
}
public void setShape( Polygon shape )
{
this.shape = shape;
}
public String getObjectId()
{
return objectId;
}
public void setObjectId( String objectId )
{
this.objectId = objectId;
}
}
List<Point> boundary = new ArrayList<>();
boundary.add( new Point().setLongitude( -77.05786152 ).setLatitude( 38.87261877 ));
boundary.add( new Point().setLongitude( -77.0546978 ).setLatitude( 38.87296123 ));
boundary.add( new Point().setLongitude( -77.05317431 ).setLatitude( 38.87061405 ));
boundary.add( new Point().setLongitude( -77.0555883 ).setLatitude( 38.86882611 ));
boundary.add( new Point().setLongitude( -77.05847435 ).setLatitude( 38.87002898 ));
boundary.add( new Point().setLongitude( -77.05786152 ).setLatitude( 38.87261877 ));
List<Point> hole = new ArrayList<>();
hole.add( new Point().setLongitude( -77.05579215 ).setLatitude( 38.87026286 ));
hole.add( new Point().setLongitude( -77.05491238 ).setLatitude( 38.87087264 ));
hole.add( new Point().setLongitude( -77.05544882 ).setLatitude( 38.87170794 ));
hole.add( new Point().setLongitude( -77.05669337 ).setLatitude( 38.87156594 ));
hole.add( new Point().setLongitude( -77.05684357 ).setLatitude( 38.87072228 ));
hole.add( new Point().setLongitude( -77.05579215 ).setLatitude( 38.87026286 ));
List<LineString> holes = new ArrayList<>();
holes.add( new LineString( hole ) );
Polygon pentagonBuildingShape = new Polygon( boundary, holes );
Building buildingObject = new Building();
buildingObject.setName( "Pentagon" );
buildingObject.setShape( pentagonBuildingShape );
Backendless.Data.of( Building.class ).save( buildingObject, new AsyncCallback<Building>()
{
@Override
public void handleResponse( Building savedBuilding )
{
String objectId = savedBuilding.getObjectId();
}
@Override
public void handleFault( BackendlessFault fault )
{
}
} );
Building class:
import com.backendless.persistence.Polygon
class Building {
var name: String? = null
var shape: Polygon? = null
var objectId: String? = null
}
val boundary = ArrayList<Point>()
boundary.add(Point().setLongitude(-77.05786152).setLatitude(38.87261877))
boundary.add(Point().setLongitude(-77.0546978).setLatitude(38.87296123))
boundary.add(Point().setLongitude(-77.05317431).setLatitude(38.87061405))
boundary.add(Point().setLongitude(-77.0555883).setLatitude(38.86882611))
boundary.add(Point().setLongitude(-77.05847435).setLatitude(38.87002898))
boundary.add(Point().setLongitude(-77.05786152).setLatitude(38.87261877))
val hole = ArrayList<Point>()
hole.add(Point().setLongitude(-77.05579215).setLatitude(38.87026286))
hole.add(Point().setLongitude(-77.05491238).setLatitude(38.87087264))
hole.add(Point().setLongitude(-77.05544882).setLatitude(38.87170794))
hole.add(Point().setLongitude(-77.05669337).setLatitude(38.87156594))
hole.add(Point().setLongitude(-77.05684357).setLatitude(38.87072228))
hole.add(Point().setLongitude(-77.05579215).setLatitude(38.87026286))
val holes = ArrayList<LineString>()
holes.add(LineString(hole))
val pentagonBuildingShape = Polygon(boundary, holes)
val buildingObject = Building()
buildingObject.name = "Pentagon"
buildingObject.shape = pentagonBuildingShape
Backendless.Data.of(Building::class.java).save(buildingObject, object : AsyncCallback<Building> {
override fun handleResponse(savedBuilding: Building) {
val objectId = savedBuilding.objectId
}
override fun handleFault(fault: BackendlessFault) {
}
})
List<Point> boundary = new ArrayList<>();
boundary.add( new Point().setLongitude( -77.05786152 ).setLatitude( 38.87261877 ));
boundary.add( new Point().setLongitude( -77.0546978 ).setLatitude( 38.87296123 ));
boundary.add( new Point().setLongitude( -77.05317431 ).setLatitude( 38.87061405 ));
boundary.add( new Point().setLongitude( -77.0555883 ).setLatitude( 38.86882611 ));
boundary.add( new Point().setLongitude( -77.05847435 ).setLatitude( 38.87002898 ));
boundary.add( new Point().setLongitude( -77.05786152 ).setLatitude( 38.87261877 ));
List<Point> hole = new ArrayList<>();
hole.add( new Point().setLongitude( -77.05579215 ).setLatitude( 38.87026286 ));
hole.add( new Point().setLongitude( -77.05491238 ).setLatitude( 38.87087264 ));
hole.add( new Point().setLongitude( -77.05544882 ).setLatitude( 38.87170794 ));
hole.add( new Point().setLongitude( -77.05669337 ).setLatitude( 38.87156594 ));
hole.add( new Point().setLongitude( -77.05684357 ).setLatitude( 38.87072228 ));
hole.add( new Point().setLongitude( -77.05579215 ).setLatitude( 38.87026286 ));
List<LineString> holes = new ArrayList<>();
holes.add( new LineString( hole ) );
Polygon pentagonBuildingShape = new Polygon( boundary, holes );
HashMap<String, Object> buildingObject = new HashMap<>();
buildingObject.put( "name", "Pentagon" );
buildingObject.put( "shape", pentagonBuildingShape );
Backendless.Data.of( "Building" ).save( buildingObject, new AsyncCallback<Map>()
{
@Override
public void handleResponse( Map savedBuilding )
{
String objectId = (String) savedBuilding.get( "objectId" );
}
@Override
public void handleFault( BackendlessFault fault )
{
}
} );
val boundary = ArrayList<Point>()
boundary.add(Point().setLongitude(-77.05786152).setLatitude(38.87261877))
boundary.add(Point().setLongitude(-77.0546978).setLatitude(38.87296123))
boundary.add(Point().setLongitude(-77.05317431).setLatitude(38.87061405))
boundary.add(Point().setLongitude(-77.0555883).setLatitude(38.86882611))
boundary.add(Point().setLongitude(-77.05847435).setLatitude(38.87002898))
boundary.add(Point().setLongitude(-77.05786152).setLatitude(38.87261877))
val hole = ArrayList<Point>()
hole.add(Point().setLongitude(-77.05579215).setLatitude(38.87026286))
hole.add(Point().setLongitude(-77.05491238).setLatitude(38.87087264))
hole.add(Point().setLongitude(-77.05544882).setLatitude(38.87170794))
hole.add(Point().setLongitude(-77.05669337).setLatitude(38.87156594))
hole.add(Point().setLongitude(-77.05684357).setLatitude(38.87072228))
hole.add(Point().setLongitude(-77.05579215).setLatitude(38.87026286))
val holes = ArrayList<LineString>()
holes.add(LineString(hole))
val pentagonBuildingShape = Polygon(boundary, holes)
val buildingObject = HashMap<String, Any>()
buildingObject.put("name", "Pentagon")
buildingObject.put("shape", pentagonBuildingShape)
Backendless.Data.of("Building").save(buildingObject, object : AsyncCallback<Map<Any?, Any?>> {
override fun handleResponse(savedBuilding: Map<Any?, Any?>) {
val objectId = savedBuilding["objectId"] as String?
}
override fun handleFault(fault: BackendlessFault) {
}
})
Codeless Reference
The example below creates a new object containing one GeoJSON (Polygon
) object and saves it to the database called geolocation
:
where:
Argument | Description |
---|---|
table name |
Name of the data table where a new record must be saved. |
object |
An object to save in the database. Object properties must match the names of the table columns. The object must not have the objectId property. |
return result |
Optional parameter. When this box is checked, the operation returns the saved object with the objectId property. |
After running the code(or Codeless Logic), you will see the following object in the database: