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,
com.google.maps.model.LatLng[] latLngs)
Add a LineString geometry object into the GeoJSON
|
static String |
addLineString(String geojson,
com.google.maps.model.LatLng[] latLngs,
Map<String,Object> properties)
Add a LineString geometry object into the GeoJSON with properties
|
static String |
addLineString(String geojson,
com.google.maps.model.LatLng[] latLngs,
String typeUri)
Add a LineString geometry object into the GeoJSON with a type
|
static String |
addLineString(String geojson,
com.google.maps.model.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,
com.google.maps.model.LatLng latLng)
Add a Point geometry object into the GeoJSON
|
static String |
addPoint(String geojson,
com.google.maps.model.LatLng latLng,
Map<String,Object> properties)
Add a Point geometry object into the GeoJSON with properties
|
static String |
addPoint(String geojson,
com.google.maps.model.LatLng latLng,
String typeUri)
Add a Point geometry object into the GeoJSON with a type
|
static String |
addPoint(String geojson,
com.google.maps.model.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,
com.google.maps.model.LatLng latLng,
String text)
Add a TextString geometry object into the GeoJSON
|
static String |
addTextString(String geojson,
com.google.maps.model.LatLng latLng,
String text,
Map<String,Object> properties)
Add a TextString geometry object into the GeoJSON with properties
|
static double |
computeDistance(com.google.maps.model.LatLng p1,
com.google.maps.model.LatLng p2)
Compute the surface distance between two coordinates.
|
static double |
computeDistanceToPolygon(com.google.maps.model.LatLng point,
com.google.maps.model.LatLng[] polygon)
Returns the closest distance between the given point and polygon.
|
static double |
computeHeading(com.google.maps.model.LatLng from,
com.google.maps.model.LatLng to)
Compute the heading from point 1 to point 2.
|
static com.google.maps.model.LatLng |
computeOffset(com.google.maps.model.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<com.google.maps.model.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<com.google.maps.model.LatLng> |
getAllMarkersCoordinate(String geojson,
String typeUri)
Gets the coordinate of all the Points that have been assigned a
particular type.
|
static List<com.google.maps.model.LatLng[]> |
getAllPolygonsVertices(String geojson,
String typeUri)
Gets the coordinates of the vertices of all the Polygons that have been
assigned a particular type.
|
static com.google.maps.model.LatLng |
getClosestPointOnPolygon(com.google.maps.model.LatLng point,
com.google.maps.model.LatLng[] polygon)
Returns the coordinate on a polygon that is closest to the given point.
|
static Map<com.google.maps.model.LatLng,Double> |
getElevations(com.google.maps.model.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 com.google.maps.model.LatLng[] |
getLineStringVertices(String geojson,
String typeUri)
Gets the coordinates of the vertices of the LineString that has been
assigned a particular type.
|
static com.google.maps.model.LatLng |
getMarkerCoordinate(String geojson,
String typeUri)
Gets the coordinate of the Point that has been assigned a particular
type.
|
static com.google.maps.model.LatLng[] |
getPolygonVertices(String geojson,
String typeUri)
Gets the coordinates of the vertices of the Polygon that has been
assigned a particular type.
|
static com.google.maps.model.LatLng |
interpolate(com.google.maps.model.LatLng from,
com.google.maps.model.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(com.google.maps.model.LatLng point,
com.google.maps.model.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 com.google.maps.model.LatLng |
projectPointToLine(com.google.maps.model.LatLng point,
com.google.maps.model.LatLng line_endA,
com.google.maps.model.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, com.google.maps.model.LatLng[] latLngs)
geojson
- The GeoJSON to be modifiedlatLngs
- The list of coordinate points that makes up the LineStringpublic static String addLineString(String geojson, com.google.maps.model.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, com.google.maps.model.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, com.google.maps.model.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, com.google.maps.model.LatLng latLng)
geojson
- The GeoJSON to be modifiedlatLng
- The coordinate of the Pointpublic static String addPoint(String geojson, com.google.maps.model.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, com.google.maps.model.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, com.google.maps.model.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, com.google.maps.model.LatLng latLng, String text)
geojson
- The GeoJSON to be modifiedlatLng
- The coordinate of the Pointtext
- Input textpublic static String addTextString(String geojson, com.google.maps.model.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(com.google.maps.model.LatLng p1, com.google.maps.model.LatLng p2)
p1
- The coordinate of the first pointp2
- The coordinate of the second pointpublic static double computeDistanceToPolygon(com.google.maps.model.LatLng point, com.google.maps.model.LatLng[] polygon)
point
- The coordinate of the Pointpolygon
- The coordinates array of the vertices of the Polygonpublic static double computeHeading(com.google.maps.model.LatLng from, com.google.maps.model.LatLng to)
from
- The coordinate of the origin pointto
- The coordinate of the ending pointpublic static com.google.maps.model.LatLng computeOffset(com.google.maps.model.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<com.google.maps.model.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<com.google.maps.model.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<com.google.maps.model.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 com.google.maps.model.LatLng getClosestPointOnPolygon(com.google.maps.model.LatLng point, com.google.maps.model.LatLng[] polygon)
point
- The coordinate of the Pointpolygon
- The coordinates array of the vertices of the Polygonpublic static Map<com.google.maps.model.LatLng,Double> getElevations(com.google.maps.model.LatLng[] points) throws IOException, com.google.maps.errors.ApiException, InterruptedException, IMCException
points
- The list of coordinates to get elevation data forIOException
com.google.maps.errors.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 com.google.maps.model.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 com.google.maps.model.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 com.google.maps.model.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 com.google.maps.model.LatLng interpolate(com.google.maps.model.LatLng from, com.google.maps.model.LatLng to, double fraction)
from
- The coordinate of the origin pointto
- The coordinate of the ending pointfraction
- public static boolean isPointInsidePolygon(com.google.maps.model.LatLng point, com.google.maps.model.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 com.google.maps.model.LatLng projectPointToLine(com.google.maps.model.LatLng point, com.google.maps.model.LatLng line_endA, com.google.maps.model.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