public final class MapUtil extends Object
Modifier and Type | Field and Description |
---|---|
static double |
EARTH_RADIUS
The radius of the earth used in all of the calculations, in meter
|
Constructor and Description |
---|
MapUtil(BaseContext ctx) |
Modifier and Type | Method and Description |
---|---|
static String |
addLineString(String geojson,
LatLng[] latLngs)
Add a LineString geometry object into the GeoJSON
|
static String |
addLineString(String geojson,
LatLng[] latLngs,
Map<String,Object> properties)
Add a LineString geometry object into the GeoJSON with properties
|
static String |
addLineString(String geojson,
LatLng[] latLngs,
String typeUri)
Add a LineString geometry object into the GeoJSON with a type
|
static String |
addLineString(String geojson,
LatLng[] latLngs,
String typeUri,
Map<String,Object> properties)
Add a LineString geometry object into the GeoJSON with a type and
properties
|
static String |
addPoint(String geojson,
LatLng latLng)
Add a Point geometry object into the GeoJSON
|
static String |
addPoint(String geojson,
LatLng latLng,
Map<String,Object> properties)
Add a Point geometry object into the GeoJSON with properties
|
static String |
addPoint(String geojson,
LatLng latLng,
String typeUri)
Add a Point geometry object into the GeoJSON with a type
|
static String |
addPoint(String geojson,
LatLng latLng,
String typeUri,
Map<String,Object> properties)
Add a Point geometry object into the GeoJSON with a type and properties
|
static String |
addTextString(String geojson,
LatLng latLng,
String text)
Add a TextString geometry object into the GeoJSON
|
static String |
addTextString(String geojson,
LatLng latLng,
String text,
Map<String,Object> properties)
Add a TextString geometry object into the GeoJSON with properties
|
static double |
computeDistance(LatLng p1,
LatLng p2)
Compute the surface distance between two coordinates.
|
static double |
computeDistanceToPolygon(LatLng point,
LatLng[] polygon)
Returns the closest distance between the given point and polygon.
|
static double |
computeHeading(LatLng from,
LatLng to)
Compute the heading from point 1 to point 2.
|
static LatLng |
computeOffset(LatLng from,
double distance,
double heading)
Compute the coordinate of the point that would be the result of moving a
certain distance from a point in the given direction.
|
static List<LatLng[]> |
getAllLineStringsVertices(String geojson,
String typeUri)
Gets the coordinates of the vertices of all the LineStrings that have
been assigned a particular type.
|
static List<LatLng> |
getAllMarkersCoordinate(String geojson,
String typeUri)
Gets the coordinate of all the Points that have been assigned a
particular type.
|
static List<LatLng[]> |
getAllPolygonsVertices(String geojson,
String typeUri)
Gets the coordinates of the vertices of all the Polygons that have been
assigned a particular type.
|
static LatLng |
getClosestPointOnPolygon(LatLng point,
LatLng[] polygon)
Returns the coordinate on a polygon that is closest to the given point.
|
static Map<LatLng,Double> |
getElevations(LatLng[] points)
Retrieves the elevation data for the given coordinates.
|
static Object |
getFeatureProperty(String geojson,
String typeUri,
String propertyName)
Gets a property of the feature that has been assigned a particular type.
|
static LatLng[] |
getLineStringVertices(String geojson,
String typeUri)
Gets the coordinates of the vertices of the LineString that has been
assigned a particular type.
|
static LatLng |
getMarkerCoordinate(String geojson,
String typeUri)
Gets the coordinate of the Point that has been assigned a particular
type.
|
static LatLng[] |
getPolygonVertices(String geojson,
String typeUri)
Gets the coordinates of the vertices of the Polygon that has been
assigned a particular type.
|
static LatLng |
interpolate(LatLng from,
LatLng to,
double fraction)
Compute the coordinate of the point which lies the given fraction of the
way between the origin and the ending point.
|
static boolean |
isPointInsidePolygon(LatLng point,
LatLng[] polygon)
Checks if point lies on or inside a closed polygon.
|
static boolean |
isUsingImperialUnits(String geojson)
Whether the properties in the GeoJSON is in terms of Imperial units (i.e.
|
static boolean |
isUsingMetricUnits(String geojson)
Whether the properties in the GeoJSON is in terms of Metric units (i.e.
|
static LatLng |
projectPointToLine(LatLng point,
LatLng line_endA,
LatLng line_endB)
Compute the coordinate of the point which is the projection of a point to
a line.
|
static String |
removeFeatureById(String geojson,
String id)
Remove the feature that has the given feature id
|
static String |
removeFeatureByType(String geojson,
String typeURI)
Remove the feature that has the given type
|
static String |
updateFeatureProperty(String geojson,
String typeURI,
String propertyName,
Object propertyValue)
Updates the property of the feature that has the given type
|
public static double EARTH_RADIUS
public static String addLineString(String geojson, LatLng[] latLngs)
geojson
- The GeoJSON to be modifiedlatLngs
- The list of coordinate points that makes up the LineStringpublic static String addLineString(String geojson, LatLng[] latLngs, Map<String,Object> properties)
geojson
- The GeoJSON to be modifiedlatLngs
- The list of coordinate points that makes up the LineStringproperties
- The list of key-value pairs to be set as the
LineString's propertiespublic static String addLineString(String geojson, LatLng[] latLngs, String typeUri)
geojson
- The GeoJSON to be modifiedlatLngs
- The list of coordinate points that makes up the LineStringtypeUri
- The URI of the Geographical Line Type master data to
assign for this LineStringpublic static String addLineString(String geojson, LatLng[] latLngs, String typeUri, Map<String,Object> properties)
geojson
- The GeoJSON to be modifiedlatLngs
- The list of coordinate points that makes up the LineStringtypeUri
- The URI of the Geographical Line Type master data to
assign for this LineStringproperties
- The list of key-value pairs to be set as the
LineString's propertiespublic static String addPoint(String geojson, LatLng latLng)
geojson
- The GeoJSON to be modifiedlatLng
- The coordinate of the Pointpublic static String addPoint(String geojson, LatLng latLng, Map<String,Object> properties)
geojson
- The GeoJSON to be modifiedlatLng
- The coordinate of the Pointproperties
- The list of key-value pairs to be set as the Point
propertiespublic static String addPoint(String geojson, LatLng latLng, String typeUri)
geojson
- The GeoJSON to be modifiedlatLng
- The coordinate of the PointtypeUri
- The URI of the Geographical Point Type master data to
assign for this Pointpublic static String addPoint(String geojson, LatLng latLng, String typeUri, Map<String,Object> properties)
geojson
- The GeoJSON to be modifiedlatLng
- The coordinate of the PointtypeUri
- The URI of the Geographical Point Type master data to
assign for this Pointproperties
- The list of key-value pairs to be set as the Point
propertiespublic static String addTextString(String geojson, LatLng latLng, String text)
geojson
- The GeoJSON to be modifiedlatLng
- The coordinate of the Pointtext
- Input textpublic static String addTextString(String geojson, LatLng latLng, String text, Map<String,Object> properties)
geojson
- The GeoJSON to be modifiedlatLng
- The coordinate of the TextStringtypeUri
- The URI of the Geographical TextString Type master data to
assign for this Pointproperties
- The list of key-value pairs to be set as the TextString
propertiespublic static double computeDistance(LatLng p1, LatLng p2)
p1
- The coordinate of the first pointp2
- The coordinate of the second pointpublic static double computeDistanceToPolygon(LatLng point, LatLng[] polygon)
point
- The coordinate of the Pointpolygon
- The coordinates array of the vertices of the Polygonpublic static double computeHeading(LatLng from, LatLng to)
from
- The coordinate of the origin pointto
- The coordinate of the ending pointpublic static LatLng computeOffset(LatLng from, double distance, double heading)
from
- The coordinate of the origin pointdistance
- The distance to move, in meterheading
- The direction to move, expressed in degrees clockwise from
North within the range [-180,180)public static List<LatLng[]> getAllLineStringsVertices(String geojson, String typeUri)
geojson
- The GeoJSON to be readtypeUri
- The URI of the type master data that has been assigned to
the LineStringpublic static List<LatLng> getAllMarkersCoordinate(String geojson, String typeUri)
geojson
- The GeoJSON to be readtypeUri
- The URI of the type master data that has been assigned to
the Pointpublic static List<LatLng[]> getAllPolygonsVertices(String geojson, String typeUri)
geojson
- The GeoJSON to be readtypeUri
- The URI of the type master data that has been assigned to
the Polygonpublic static LatLng getClosestPointOnPolygon(LatLng point, LatLng[] polygon)
point
- The coordinate of the Pointpolygon
- The coordinates array of the vertices of the Polygonpublic static Map<LatLng,Double> getElevations(LatLng[] points) throws IOException, ApiException, InterruptedException, IMCException
points
- The list of coordinates to get elevation data forIOException
ApiException
InterruptedException
IMCException
public static Object getFeatureProperty(String geojson, String typeUri, String propertyName)
geojson
- The GeoJSON to be readtypeUri
- The URI of the type master data that has been assigned to
the featurepropertyName
- The name of the property to retrievepublic static LatLng[] getLineStringVertices(String geojson, String typeUri)
geojson
- The GeoJSON to be readtypeUri
- The URI of the type master data that has been assigned to
the LineStringpublic static LatLng getMarkerCoordinate(String geojson, String typeUri)
geojson
- The GeoJSON to be readtypeUri
- The URI of the type master data that has been assigned to
the Pointpublic static LatLng[] getPolygonVertices(String geojson, String typeUri)
geojson
- The GeoJSON to be readtypeUri
- The URI of the type master data that has been assigned to
the Polygonpublic static LatLng interpolate(LatLng from, LatLng to, double fraction)
from
- The coordinate of the origin pointto
- The coordinate of the ending pointfraction
- public static boolean isPointInsidePolygon(LatLng point, LatLng[] polygon)
point
- The coordinate of the pointpolygon
- The list of coordinates of the polygon's vertexpublic static boolean isUsingImperialUnits(String geojson)
geojson
- The GeoJSON to be readpublic static boolean isUsingMetricUnits(String geojson)
geojson
- The GeoJSON to be readpublic static LatLng projectPointToLine(LatLng point, LatLng line_endA, LatLng line_endB)
point
- The coordinate of the pointline_endA
- The coordinate of the starting point of the lineline_endB
- The coordinate of the ending point of the linepublic static String removeFeatureById(String geojson, String id)
geojson
- The GeoJSON to be modifiedid
- The id of the featurepublic static String removeFeatureByType(String geojson, String typeURI)
geojson
- The GeoJSON to be modifiedtypeUri
- The URI of the type master data that has been assigned to
the featurepublic static String updateFeatureProperty(String geojson, String typeURI, String propertyName, Object propertyValue)
geojson
- The GeoJSON to be modifiedtypeUri
- The URI of the type master data that has been assigned to
the featurepropertyName
- The name of the property to be updatedpropertyValue
- The value of the property to be updated