Package globus.glmap

Class GLMapVectorObject

java.lang.Object
globus.glmap.GLNativeObject
globus.glmap.GLMapVectorObject
All Implemented Interfaces:
GLMapTagsContainer

public class GLMapVectorObject extends GLNativeObject implements 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).

  • Field Details

    • drawAttributes

      @Nullable public GLMapVectorStyle drawAttributes
      Draw attributes of object. Filled by updateDrawAttributes functions.
  • Method Details

    • compare

      public int compare(@Nullable GLMapVectorObject other)
      Compares objects for sorting.
      Parameters:
      other - other object
      Returns:
      a negative value if this object is less than other, 0 if they are equal, or a positive value if this object is greater than other
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(@Nullable Object other)
      Overrides:
      equals in class Object
    • createFromGeoJSONOrError

      public static Object createFromGeoJSONOrError(@NonNull String geoJSON)
      Creates vector objects from a GeoJSON string.
      Parameters:
      geoJSON - source string with geo JSON data
      Returns:
      GLMapVectorObjectList on success, or GLMapError on 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

      @Nullable public static Object createFromGeoJSONStreamOrError(@NonNull InputStream geoJSON)
      Creates vector objects from a GeoJSON stream.
      Parameters:
      geoJSON - stream with geo JSON data
      Returns:
      GLMapVectorObjectList on success, or GLMapError on 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

      @NonNull public static GLMapVectorObject createMultiline(@NonNull MapPoint[][] multilinePoints)
      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

      @NonNull public static GLMapVectorObject createPoint(@NonNull MapPoint point)
      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

      @NonNull public static GLMapVectorObject createGeoPoint(@NonNull MapGeoPoint point)
      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 polygon
      innerRings - 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 from start to end. Useful to display plane routes.
      Parameters:
      start - Start point
      end - End point
      quality - 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

      @NonNull public MapPoint point()
      Retrieves a point associated with this vector object.
      Returns:
      A MapPoint representing a point belonging to the object.
    • getBBox

      @NonNull public GLMapBBox getBBox()
      Retrieves the bounding box of this vector object.
      Returns:
      A GLMapBBox representing the object's bounding box.
    • getMultilinePoints

      @Nullable public MapPoint[][] getMultilinePoints()
      Retrieves the points of a multiline for an object whose type is GLMapVectorObject.Type.Line.
      Returns:
      A two-dimensional array of MapPoint objects, or null if the object is not of type GLMapVectorObject.Type.Line.
    • getMultilineGeoPoints

      @Nullable public MapGeoPoint[][] getMultilineGeoPoints()
      Retrieves the geo-referenced points of a multiline for an object whose type is GLMapVectorObject.Type.Line.
      Returns:
      A two-dimensional array of MapGeoPoint objects, or null if the object is not of type GLMapVectorObject.Type.Line.
    • asGeoJSON

      @Nullable public String 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, from GLMapViewRenderer.convertDisplayToInternal(double, double))
      distanceInPoints - maximum distance from the object in screen points (dp)
      Returns:
      nearest point on the object in internal map coordinates, or null if the object is too far
    • valueForKey

      @Nullable public GLMapValue valueForKey(String key)
      Description copied from interface: GLMapTagsContainer
      Returns value for the key
      Specified by:
      valueForKey in interface GLMapTagsContainer
      Parameters:
      key - Key of requested value
      Returns:
      value associated with given key. (if loaded from geo JSON get values from "properties" section)
    • valuesForKey

      @Nullable public GLMapValue[] valuesForKey(String key)
      Description copied from interface: GLMapTagsContainer
      Returns values for the key
      Specified by:
      valuesForKey in interface GLMapTagsContainer
      Parameters:
      key - Key of requested values
      Returns:
      array of values associated with given key
    • setValueForKey

      public void setValueForKey(@NonNull String key, @Nullable String value)
      Description copied from interface: GLMapTagsContainer
      Sets value for key
      Specified by:
      setValueForKey in interface GLMapTagsContainer
      Parameters:
      key - Key of value
      value - value to set
    • localizedName

      @Nullable public GLMapValue localizedName(@NonNull GLMapLocaleSettings localeSettings)
      Description copied from interface: GLMapTagsContainer
      Returns localized name.
      Specified by:
      localizedName in interface GLMapTagsContainer
      Parameters:
      localeSettings - locale settings to use
      Returns:
      name of object
    • copyProperties

      public void copyProperties(GLMapTagsContainer other)
      Description copied from interface: GLMapTagsContainer
      Copies all properties from another tags container object.
      Specified by:
      copyProperties in interface GLMapTagsContainer
      Parameters:
      other - Other tags container.
    • updateDrawAttributes

      public boolean updateDrawAttributes(@NonNull GLMapViewRenderer mapView, @Nullable GLMapVectorCascadeStyle style)
      Updates draw attributes
      Parameters:
      mapView - view where object is displayed
      style - style of object or null to 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 object
      localeSettings - locale settings
      zoomLevel - zoom to test
      Returns:
      true if visible
    • updateDrawAttributes

      public boolean updateDrawAttributes(@NonNull GLMapViewRenderer mapView)
      Updates draw attributes
      Parameters:
      mapView - view where object is displayed
      Returns:
      true if visible