Package globus.glmap
Class GLMapVectorObject
java.lang.Object
globus.glmap.GLNativeObject
globus.glmap.GLMapVectorObject
- All Implemented Interfaces:
GLMapTagsContainer
A bridge class for working with GLMap's internal representation of a vector object.
A vector object may represent a point, line, or polygon and can be created from GeoJSON or
built programmatically (see the create* methods).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceDefines the types of vector objects. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionSerialize object as GeoJSONintcompare(GLMapVectorObject other) Compares objects for sorting.voidcopyProperties(GLMapTagsContainer other) Copies all properties from another tags container object.static ObjectcreateFromGeoJSONOrError(String geoJSON) Creates vector objects from a GeoJSON string.static GLMapVectorObjectListcreateFromGeoJSONOrThrow(String geoJSON) Create objects from geo-json string throws if error happensstatic ObjectCreates vector objects from a GeoJSON stream.static GLMapVectorObjectListCreate objects from geo-json streamstatic GLMapVectorObjectcreateGeoLine(MapGeoPoint start, MapGeoPoint end, double quality) Creates a great-circle line fromstarttoend.static GLMapVectorObjectcreateGeoPoint(MapGeoPoint point) Creates a vector object with point geometry in geographic coordinates (WGS84 degrees).static GLMapVectorObjectcreateMultiline(MapPoint[][] multilinePoints) Creates a vector object with multiline geometry from internal map coordinates.static GLMapVectorObjectcreateMultilineGeo(MapGeoPoint[][] multilinePoints) Creates a vector object with multiline geometry in geographic coordinates (WGS84 degrees).static GLMapVectorObjectcreatePoint(MapPoint point) Creates a vector object with point geometry in internal map coordinates.static GLMapVectorObjectcreatePolygon(MapPoint[][] outerRings, MapPoint[][] innerRings) Creates a vector object with polygon geometry from internal map coordinates.static GLMapVectorObjectcreatePolygonGeo(MapGeoPoint[][] outerRings, MapGeoPoint[][] innerRings) Creates a vector object with polygon geometry in geographic coordinates (WGS84 degrees).booleanfindNearestPoint(GLMapViewRenderer renderer, MapPoint point, double distanceInPoints) Finds the nearest point on the object to the provided map point.getBBox()Retrieves the bounding box of this vector object.MapGeoPoint[][]Retrieves the geo-referenced points of a multiline for an object whose type isGLMapVectorObject.Type.Line.MapPoint[][]Retrieves the points of a multiline for an object whose type isGLMapVectorObject.Type.Line.intgetType()Retrieves the type of this vector object.inthashCode()localizedName(GLMapLocaleSettings localeSettings) Returns localized name.point()Retrieves a point associated with this vector object.voidsetValueForKey(String key, String value) Sets value for keybooleanupdateDrawAttributes(GLMapVectorCascadeStyle style, GLMapLocaleSettings localeSettings, int zoomLevel) Updates draw attributesbooleanupdateDrawAttributes(GLMapViewRenderer mapView) Updates draw attributesbooleanupdateDrawAttributes(GLMapViewRenderer mapView, GLMapVectorCascadeStyle style) Updates draw attributesvalueForKey(String key) Returns value for the keyvaluesForKey(String key) Returns values for the keyMethods inherited from class globus.glmap.GLNativeObject
dispose
-
Field Details
-
drawAttributes
Draw attributes of object. Filled by updateDrawAttributes functions.
-
-
Method Details
-
compare
Compares objects for sorting.- Parameters:
other- other object- Returns:
- a negative value if this object is less than
other,0if they are equal, or a positive value if this object is greater thanother
-
hashCode
public int hashCode() -
equals
-
createFromGeoJSONOrError
Creates vector objects from a GeoJSON string.- Parameters:
geoJSON- source string with geo JSON data- Returns:
GLMapVectorObjectListon success, orGLMapErroron failure
-
createFromGeoJSONOrThrow
public static GLMapVectorObjectList createFromGeoJSONOrThrow(@NonNull String geoJSON) throws Exception Create objects from geo-json string throws if error happens- Parameters:
geoJSON- geo-json string- Returns:
- vector objects
- Throws:
Exception- if error happens
-
createFromGeoJSONStreamOrError
Creates vector objects from a GeoJSON stream.- Parameters:
geoJSON- stream with geo JSON data- Returns:
GLMapVectorObjectListon success, orGLMapErroron failure
-
createFromGeoJSONStreamOrThrow
@NonNull public static GLMapVectorObjectList createFromGeoJSONStreamOrThrow(@NonNull InputStream geoJSON) throws Exception Create objects from geo-json stream- Parameters:
geoJSON- geo-json stream- Returns:
- vector objects
- Throws:
Exception- if an error happens
-
createMultiline
Creates a vector object with multiline geometry from internal map coordinates.MapPoint[] line1 = { MapPoint.CreateFromGeoCoordinates(53.8869, 27.7151), // Minsk MapPoint.CreateFromGeoCoordinates(50.4339, 30.5186), // Kyiv }; MapPoint[] line2 = { MapPoint.CreateFromGeoCoordinates(52.3690, 4.9021), // Amsterdam MapPoint.CreateFromGeoCoordinates(50.8263, 4.3458), // Brussels }; GLMapVectorObject obj = GLMapVectorObject.createMultiline(new MapPoint[][] {line1, line2});- Parameters:
multilinePoints- Multiline points in internal map coordinates.- Returns:
- Created vector object with multiline geometry.
- See Also:
-
createMultilineGeo
@NonNull public static GLMapVectorObject createMultilineGeo(@NonNull MapGeoPoint[][] multilinePoints) Creates a vector object with multiline geometry in geographic coordinates (WGS84 degrees).- Parameters:
multilinePoints- Multiline points in geographic coordinates.- Returns:
- Created vector object with multiline geometry.
-
createPoint
Creates a vector object with point geometry in internal map coordinates.- Parameters:
point- Point in internal map coordinates.- Returns:
- Created vector object with point geometry.
- See Also:
-
createGeoPoint
Creates a vector object with point geometry in geographic coordinates (WGS84 degrees).- Parameters:
point- Point in geographic coordinates.- Returns:
- Created vector object with point geometry.
-
createPolygon
@NonNull public static GLMapVectorObject createPolygon(@NonNull MapPoint[][] outerRings, @Nullable MapPoint[][] innerRings) Creates a vector object with polygon geometry from internal map coordinates.MapPoint[][] outerRings = {outerRing1, outerRing2}; MapPoint[][] innerRings = {innerRing1, innerRing2}; GLMapVectorObject polygon = GLMapVectorObject.createPolygon(outerRings, innerRings);- Parameters:
outerRings- outer rings of polygon.innerRings- inner rings of polygons (holes).- Returns:
- Created vector object with polygon geometry.
- See Also:
-
createPolygonGeo
@NonNull public static GLMapVectorObject createPolygonGeo(@NonNull MapGeoPoint[][] outerRings, @Nullable MapGeoPoint[][] innerRings) Creates a vector object with polygon geometry in geographic coordinates (WGS84 degrees).- Parameters:
outerRings- outer rings of polygoninnerRings- inner rings of polygon (holes)- Returns:
- Created vector object with polygon geometry
-
createGeoLine
@NonNull public static GLMapVectorObject createGeoLine(@NonNull MapGeoPoint start, @NonNull MapGeoPoint end, double quality) Creates a great-circle line fromstarttoend. Useful to display plane routes.- Parameters:
start- Start pointend- End pointquality- Maximum distance from point to line, used for simplification in Douglas Peucker algorithm. Units are internal map coordinates.- Returns:
- Created vector object with geo-line.
-
getType
public int getType()Retrieves the type of this vector object.- Returns:
- The type of the object, which can be one of the constants defined in
GLMapVectorObject.Type.
-
point
Retrieves a point associated with this vector object.- Returns:
- A
MapPointrepresenting a point belonging to the object.
-
getBBox
Retrieves the bounding box of this vector object.- Returns:
- A
GLMapBBoxrepresenting the object's bounding box.
-
getMultilinePoints
Retrieves the points of a multiline for an object whose type isGLMapVectorObject.Type.Line.- Returns:
- A two-dimensional array of
MapPointobjects, ornullif the object is not of typeGLMapVectorObject.Type.Line.
-
getMultilineGeoPoints
Retrieves the geo-referenced points of a multiline for an object whose type isGLMapVectorObject.Type.Line.- Returns:
- A two-dimensional array of
MapGeoPointobjects, ornullif the object is not of typeGLMapVectorObject.Type.Line.
-
asGeoJSON
Serialize object as GeoJSON- Returns:
- GeoJSON string
-
findNearestPoint
@Nullable public MapPoint findNearestPoint(@NonNull GLMapViewRenderer renderer, @NonNull MapPoint point, double distanceInPoints) Finds the nearest point on the object to the provided map point.- Parameters:
renderer- renderer where the object is displayed (must be attached to a surface to compute screen distances)point- reference point in internal map coordinates (for example, fromGLMapViewRenderer.convertDisplayToInternal(double, double))distanceInPoints- maximum distance from the object in screen points (dp)- Returns:
- nearest point on the object in internal map coordinates, or
nullif the object is too far
-
valueForKey
Description copied from interface:GLMapTagsContainerReturns value for the key- Specified by:
valueForKeyin interfaceGLMapTagsContainer- Parameters:
key- Key of requested value- Returns:
- value associated with given key. (if loaded from geo JSON get values from "properties" section)
-
valuesForKey
Description copied from interface:GLMapTagsContainerReturns values for the key- Specified by:
valuesForKeyin interfaceGLMapTagsContainer- Parameters:
key- Key of requested values- Returns:
- array of values associated with given key
-
setValueForKey
Description copied from interface:GLMapTagsContainerSets value for key- Specified by:
setValueForKeyin interfaceGLMapTagsContainer- Parameters:
key- Key of valuevalue- value to set
-
localizedName
Description copied from interface:GLMapTagsContainerReturns localized name.- Specified by:
localizedNamein interfaceGLMapTagsContainer- Parameters:
localeSettings- locale settings to use- Returns:
- name of object
-
copyProperties
Description copied from interface:GLMapTagsContainerCopies all properties from another tags container object.- Specified by:
copyPropertiesin interfaceGLMapTagsContainer- Parameters:
other- Other tags container.
-
updateDrawAttributes
public boolean updateDrawAttributes(@NonNull GLMapViewRenderer mapView, @Nullable GLMapVectorCascadeStyle style) Updates draw attributes- Parameters:
mapView- view where object is displayedstyle- style of object ornullto use the map view style- Returns:
- true if visible
-
updateDrawAttributes
public boolean updateDrawAttributes(@NonNull GLMapVectorCascadeStyle style, @NonNull GLMapLocaleSettings localeSettings, int zoomLevel) Updates draw attributes- Parameters:
style- style of objectlocaleSettings- locale settingszoomLevel- zoom to test- Returns:
- true if visible
-
updateDrawAttributes
Updates draw attributes- Parameters:
mapView- view where object is displayed- Returns:
- true if visible
-