Package globus.glmap

Class GLMapVectorObject

java.lang.Object
globus.glmap.GLNativeObject
globus.glmap.GLMapVectorObject
All Implemented Interfaces:
GLMapTagsContainer, AutoCloseable
Direct Known Subclasses:
GLMapVectorLine, GLMapVectorPoint, GLMapVectorPolygon, GLMapVectorRelation

public class GLMapVectorObject extends GLNativeObject implements GLMapTagsContainer
A bridge class for working with GLMap's internal representation of a vector object.

Instances are GLMapVectorPoint, GLMapVectorLine or GLMapVectorPolygon. They are created from GeoJSON, by GeometryBuilder, or by the subclass constructors.

  • 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

      @Deprecated @NonNull public static GLMapVectorObject createMultiline(@NonNull MapPoint[][] multilinePoints)
      Deprecated.
      Use GeometryBuilder.addLine(MapPoint[]) for each line. Will be removed in 2.4.0.
      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

      @Deprecated @NonNull public static GLMapVectorObject createMultilineGeo(@NonNull MapGeoPoint[][] multilinePoints)
      Deprecated.
      Use GeometryBuilder.addGeoLine(MapGeoPoint[]) for each line. Will be removed in 2.4.0.
      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

      @Deprecated @NonNull public static GLMapVectorObject createPoint(@NonNull MapPoint point)
      Deprecated.
      Use GLMapVectorPoint(MapPoint). Will be removed in 2.4.0.
      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

      @Deprecated @NonNull public static GLMapVectorObject createGeoPoint(@NonNull MapGeoPoint point)
      Deprecated.
      Use GLMapVectorPoint(MapPoint) with MapPoint(MapGeoPoint). Will be removed in 2.4.0.
      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

      @Deprecated @NonNull public static GLMapVectorObject createPolygon(@NonNull MapPoint[][] polygon)
      Deprecated.
      Use GeometryBuilder.beginPolygon() and GeometryBuilder.addLine(MapPoint[]) for each ring. Will be removed in 2.4.0.
      Creates a vector object with polygon geometry from internal map coordinates.
      
       MapPoint[][] polygon = {outerRing1, innerRing1, innerRing2};
       GLMapVectorObject polygon = GLMapVectorObject.createPolygon(polygon);
       
      Parameters:
      polygon - first array is outer ring next is inner rings
      Returns:
      Created vector object with polygon geometry.
      See Also:
    • createPolygonGeo

      @Deprecated @NonNull public static GLMapVectorObject createPolygonGeo(@NonNull MapGeoPoint[][] polygon)
      Deprecated.
      Use GeometryBuilder.beginPolygon() and GeometryBuilder.addGeoLine(MapGeoPoint[]) for each ring. Will be removed in 2.4.0.
      Creates a vector object with polygon geometry in geographic coordinates (WGS84 degrees).
      Parameters:
      polygon - first array is outer ring next is inner rings
      Returns:
      Created vector object with polygon geometry
    • createGeoLine

      @Deprecated @NonNull public static GLMapVectorObject createGeoLine(@NonNull MapGeoPoint start, @NonNull MapGeoPoint end, double quality)
      Deprecated.
      Creates a great-circle line from start to end. Useful to display plane routes.
      Parameters:
      start - Start point
      end - End point
      quality - subdivision step in meters: the line is split until its half-segments are shorter than this, into at most 65536 segments
      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.
    • asGeoJSON

      @Nullable public String asGeoJSON()
      Serialize object as GeoJSON
      Returns:
      GeoJSON string
    • 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.
    • getPointCount

      public int getPointCount()
      Returns:
      The total number of points in the geometry.
    • getLineCount

      public int getLineCount()
      Returns:
      The number of line segments (including polygon outlines) in the geometry.
    • getPolygonCount

      public int getPolygonCount()
      Returns:
      The number of polygons in the geometry.
    • getLinePointStart

      public int getLinePointStart(int lineIndex)
      Returns the start index of the point range for the given line.
      Parameters:
      lineIndex - The index of the line (0 <= lineIndex < getLineCount()).
      Returns:
      The absolute index of the first point of that line.
    • getLinePointCount

      public int getLinePointCount(int lineIndex)
      Returns the number of points in the given line.
      Parameters:
      lineIndex - The index of the line (0 <= lineIndex < getLineCount()).
      Returns:
      The count of points belonging to that line.
    • getPolygonLineStart

      public int getPolygonLineStart(int polygonIndex)
      Returns the start index of the line range for the given polygon.
      Parameters:
      polygonIndex - The index of the polygon (0 <= polygonIndex < getPolygonCount()).
      Returns:
      The index of the first line that makes up that polygon.
    • getPolygonLineCount

      public int getPolygonLineCount(int polygonIndex)
      Returns the number of lines in the given polygon.
      Parameters:
      polygonIndex - The index of the polygon (0 <= polygonIndex < getPolygonCount()).
      Returns:
      The count of lines belonging to that polygon.
    • getPointAtIndex

      public void getPointAtIndex(int index, @NonNull MapPoint outPoint)
      Fills the provided point object with the coordinates at the given absolute index.
      Parameters:
      index - 0 <= index < getPointCount()
      outPoint - Pre-allocated GLMapPoint instance that will be filled.
    • 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