Class GoogleMapShapeConverter

java.lang.Object
mil.nga.geopackage.map.geom.GoogleMapShapeConverter

public class GoogleMapShapeConverter extends Object
Provides conversions methods between geometry object and Google Maps Android API v2 Shapes
  • Constructor Details

    • GoogleMapShapeConverter

      public GoogleMapShapeConverter()
      Constructor
      Since:
      1.3.2
    • GoogleMapShapeConverter

      public GoogleMapShapeConverter(Projection projection)
      Constructor with specified projection, see UserCoreDao.getProjection()
      Parameters:
      projection - projection
  • Method Details

    • getProjection

      public Projection getProjection()
      Get the projection
      Returns:
      projection
    • getExteriorOrientation

      public PolygonOrientation getExteriorOrientation()
      Get exterior orientation for conversions. Defaults to PolygonOrientation.COUNTERCLOCKWISE
      Returns:
      exterior orientation
      Since:
      1.3.2
    • setExteriorOrientation

      public void setExteriorOrientation(PolygonOrientation exteriorOrientation)
      Set the exterior orientation for conversions, set to null to maintain orientation
      Parameters:
      exteriorOrientation - orientation
      Since:
      1.3.2
    • getHoleOrientation

      public PolygonOrientation getHoleOrientation()
      Get polygon hole orientation for conversions. Defaults to PolygonOrientation.CLOCKWISE
      Returns:
      hole orientation
      Since:
      1.3.2
    • setHoleOrientation

      public void setHoleOrientation(PolygonOrientation holeOrientation)
      Set the polygon hole orientation for conversions, set to null to maintain orientation
      Parameters:
      holeOrientation - orientation
      Since:
      1.3.2
    • getSimplifyTolerance

      public Double getSimplifyTolerance()
      Get the simplify tolerance in meters to simplify lines and polygons to similar curves with fewer points
      Returns:
      simplify tolerance in meters, null for no simplification
    • setSimplifyTolerance

      public void setSimplifyTolerance(Double simplifyTolerance)
      Set the simplify tolerance in meters to simplify lines and polygons to similar curves with fewer points
      Parameters:
      simplifyTolerance - simplify tolerance in meters, null for no simplification
    • toWgs84

      public Point toWgs84(Point point)
      Transform a projection point to WGS84
      Parameters:
      point - projection point
      Returns:
      WGS84 point
    • toProjection

      public Point toProjection(Point point)
      Transform a WGS84 point to the projection
      Parameters:
      point - WGS84 point
      Returns:
      projection point
    • toLatLng

      public LatLng toLatLng(Point point)
      Convert a Point to a LatLng
      Parameters:
      point - point
      Returns:
      lat lng
    • toPoint

      public Point toPoint(LatLng latLng)
      Convert a LatLng to a Point
      Parameters:
      latLng - lat lng
      Returns:
      point
    • toPoint

      public Point toPoint(LatLng latLng, boolean hasZ, boolean hasM)
      Convert a LatLng to a Point
      Parameters:
      latLng - lat lng
      hasZ - has z flag
      hasM - has m flag
      Returns:
      point
    • toPolyline

      public PolylineOptions toPolyline(LineString lineString)
      Parameters:
      lineString - line string
      Returns:
      polyline options
    • toLineString

      public LineString toLineString(Polyline polyline)
      Convert a Polyline to a LineString
      Parameters:
      polyline - polyline
      Returns:
      line string
    • toLineString

      public LineString toLineString(Polyline polyline, boolean hasZ, boolean hasM)
      Convert a Polyline to a LineString
      Parameters:
      polyline - polyline
      hasZ - has z flag
      hasM - has m flag
      Returns:
      line string
    • toLineString

      public LineString toLineString(PolylineOptions polyline)
      Parameters:
      polyline - polyline options
      Returns:
      line string
    • toLineString

      public LineString toLineString(PolylineOptions polyline, boolean hasZ, boolean hasM)
      Parameters:
      polyline - polyline options
      hasZ - has z flag
      hasM - has m flag
      Returns:
      line string
    • toLineString

      public LineString toLineString(List<LatLng> latLngs)
      Convert a list of LatLng to a LineString
      Parameters:
      latLngs - lat lngs
      Returns:
      line string
    • toLineString

      public LineString toLineString(List<LatLng> latLngs, boolean hasZ, boolean hasM)
      Convert a list of LatLng to a LineString
      Parameters:
      latLngs - lat lngs
      hasZ - has z flag
      hasM - has m flag
      Returns:
      line string
    • toCircularString

      public CircularString toCircularString(List<LatLng> latLngs)
      Convert a list of LatLng to a CircularString
      Parameters:
      latLngs - lat lngs
      Returns:
      circular string
    • toCircularString

      public CircularString toCircularString(List<LatLng> latLngs, boolean hasZ, boolean hasM)
      Convert a list of LatLng to a CircularString
      Parameters:
      latLngs - lat lngs
      hasZ - has z flag
      hasM - has m flag
      Returns:
      circular string
    • populateLineString

      public void populateLineString(LineString lineString, List<LatLng> latLngs)
      Convert a list of LatLng to a LineString
      Parameters:
      lineString - line string
      latLngs - lat lngs
    • toPolygon

      public PolygonOptions toPolygon(Polygon polygon)
      Convert a Polygon to a PolygonOptions
      Parameters:
      polygon - polygon
      Returns:
      polygon options
    • toCurvePolygon

      public PolygonOptions toCurvePolygon(CurvePolygon<Curve> curvePolygon)
      Parameters:
      curvePolygon - curve polygon
      Returns:
      polygon options
      Since:
      1.4.1
    • toPolygon

      public Polygon toPolygon(Polygon polygon)
      Convert a Polygon to a Polygon
      Parameters:
      polygon - polygon
      Returns:
      polygon
    • toPolygon

      public Polygon toPolygon(Polygon polygon, boolean hasZ, boolean hasM)
      Convert a Polygon to a Polygon
      Parameters:
      polygon - polygon
      hasZ - has z flag
      hasM - has m flag
      Returns:
      polygon
    • toPolygon

      public Polygon toPolygon(PolygonOptions polygon)
      Convert a Polygon to a Polygon
      Parameters:
      polygon - polygon options
      Returns:
      polygon
    • toPolygon

      public Polygon toPolygon(PolygonOptions polygon, boolean hasZ, boolean hasM)
      Convert a Polygon to a Polygon
      Parameters:
      polygon - polygon options
      hasZ - has z flag
      hasM - has m flag
      Returns:
      polygon
    • toPolygon

      public Polygon toPolygon(List<LatLng> latLngs, List<List<LatLng>> holes)
      Convert a list of LatLng and list of hole list LatLng to a Polygon
      Parameters:
      latLngs - lat lngs
      holes - list of holes
      Returns:
      polygon
    • toPolygon

      public Polygon toPolygon(List<LatLng> latLngs, List<List<LatLng>> holes, boolean hasZ, boolean hasM)
      Convert a list of LatLng and list of hole list LatLng to a Polygon
      Parameters:
      latLngs - lat lngs
      holes - list of holes
      hasZ - has z flag
      hasM - has m flag
      Returns:
      polygon
    • closePolygonRing

      public void closePolygonRing(List<LatLng> points)
      Close the polygon ring (exterior or hole) points if needed
      Parameters:
      points - ring points
      Since:
      1.3.2
    • getOrientation

      public PolygonOrientation getOrientation(List<LatLng> points)
      Determine the closed points orientation
      Parameters:
      points - closed points
      Returns:
      orientation
      Since:
      1.3.2
    • toLatLngs

      public MultiLatLng toLatLngs(MultiPoint multiPoint)
      Convert a MultiPoint to a MultiLatLng
      Parameters:
      multiPoint - multi point
      Returns:
      multi lat lng
    • toMultiPoint

      public MultiPoint toMultiPoint(MultiLatLng latLngs)
      Convert a MultiLatLng to a MultiPoint
      Parameters:
      latLngs - lat lngs
      Returns:
      multi point
    • toMultiPoint

      public MultiPoint toMultiPoint(MultiLatLng latLngs, boolean hasZ, boolean hasM)
      Convert a MultiLatLng to a MultiPoint
      Parameters:
      latLngs - lat lngs
      hasZ - has z flag
      hasM - has m flag
      Returns:
      multi point
    • toMultiPoint

      public MultiPoint toMultiPoint(List<LatLng> latLngs)
      Convert a MultiLatLng to a MultiPoint
      Parameters:
      latLngs - lat lngs
      Returns:
      multi point
    • toMultiPoint

      public MultiPoint toMultiPoint(List<LatLng> latLngs, boolean hasZ, boolean hasM)
      Convert a MultiLatLng to a MultiPoint
      Parameters:
      latLngs - lat lngs
      hasZ - has z flag
      hasM - has m flag
      Returns:
      multi point
    • toPolylines

      public MultiPolylineOptions toPolylines(MultiLineString multiLineString)
      Parameters:
      multiLineString - multi line string
      Returns:
      multi polyline options
    • toMultiLineString

      public MultiLineString toMultiLineString(List<Polyline> polylineList)
      Convert a list of Polyline to a MultiLineString
      Parameters:
      polylineList - polyline list
      Returns:
      multi line string
    • toMultiLineString

      public MultiLineString toMultiLineString(List<Polyline> polylineList, boolean hasZ, boolean hasM)
      Convert a list of Polyline to a MultiLineString
      Parameters:
      polylineList - polyline list
      hasZ - has z flag
      hasM - has m flag
      Returns:
      multi line string
    • toMultiLineStringFromList

      public MultiLineString toMultiLineStringFromList(List<List<LatLng>> polylineList)
      Convert a list of LatLng lists to a MultiLineString
      Parameters:
      polylineList - polyline list
      Returns:
      multi line string
    • toMultiLineStringFromList

      public MultiLineString toMultiLineStringFromList(List<List<LatLng>> polylineList, boolean hasZ, boolean hasM)
      Convert a list of LatLng lists to a MultiLineString
      Parameters:
      polylineList - polyline list
      hasZ - has z flag
      hasM - has m flag
      Returns:
      multi line string
    • toCompoundCurveFromList

      public CompoundCurve toCompoundCurveFromList(List<List<LatLng>> polylineList)
      Convert a list of LatLng lists to a CompoundCurve
      Parameters:
      polylineList - polyline list
      Returns:
      compound curve
    • toCompoundCurveFromList

      public CompoundCurve toCompoundCurveFromList(List<List<LatLng>> polylineList, boolean hasZ, boolean hasM)
      Convert a list of LatLng lists to a CompoundCurve
      Parameters:
      polylineList - polyline list
      hasZ - has z flag
      hasM - has m flag
      Returns:
      compound curve
    • toMultiLineStringFromOptions

      public MultiLineString toMultiLineStringFromOptions(MultiPolylineOptions multiPolylineOptions)
      Parameters:
      multiPolylineOptions - multi polyline options
      Returns:
      multi line string
    • toMultiLineStringFromOptions

      public MultiLineString toMultiLineStringFromOptions(MultiPolylineOptions multiPolylineOptions, boolean hasZ, boolean hasM)
      Parameters:
      multiPolylineOptions - multi polyline options
      hasZ - has z flag
      hasM - has m flag
      Returns:
      multi line string
    • toCompoundCurveFromOptions

      public CompoundCurve toCompoundCurveFromOptions(MultiPolylineOptions multiPolylineOptions)
      Parameters:
      multiPolylineOptions - multi polyline options
      Returns:
      compound curve
    • toCompoundCurveFromOptions

      public CompoundCurve toCompoundCurveFromOptions(MultiPolylineOptions multiPolylineOptions, boolean hasZ, boolean hasM)
      Parameters:
      multiPolylineOptions - multi polyline options
      hasZ - has z flag
      hasM - has m flag
      Returns:
      compound curve
    • toPolygons

      public MultiPolygonOptions toPolygons(MultiPolygon multiPolygon)
      Parameters:
      multiPolygon - multi polygon
      Returns:
      multi polygon options
    • toMultiPolygon

      public MultiPolygon toMultiPolygon(List<Polygon> polygonList)
      Convert a list of Polygon to a MultiPolygon
      Parameters:
      polygonList - polygon list
      Returns:
      multi polygon
    • toMultiPolygon

      public MultiPolygon toMultiPolygon(List<Polygon> polygonList, boolean hasZ, boolean hasM)
      Convert a list of Polygon to a MultiPolygon
      Parameters:
      polygonList - polygon list
      hasZ - has z flag
      hasM - has m flag
      Returns:
      multi polygon
    • createMultiPolygon

      public MultiPolygon createMultiPolygon(List<Polygon> polygonList)
      Convert a list of Polygon to a MultiPolygon
      Parameters:
      polygonList - polygon list
      Returns:
      multi polygon
    • createMultiPolygon

      public MultiPolygon createMultiPolygon(List<Polygon> polygonList, boolean hasZ, boolean hasM)
      Convert a list of Polygon to a MultiPolygon
      Parameters:
      polygonList - polygon list
      hasZ - has z flag
      hasM - has m flag
      Returns:
      multi polygon
    • toMultiPolygonFromOptions

      public MultiPolygon toMultiPolygonFromOptions(MultiPolygonOptions multiPolygonOptions)
      Parameters:
      multiPolygonOptions - multi polygon options
      Returns:
      multi polygon
    • toMultiPolygonFromOptions

      public MultiPolygon toMultiPolygonFromOptions(MultiPolygonOptions multiPolygonOptions, boolean hasZ, boolean hasM)
      Convert a list of PolygonOptions to a MultiPolygon
      Parameters:
      multiPolygonOptions - multi polygon options
      hasZ - has z flag
      hasM - has m flag
      Returns:
      multi polygon
    • toPolylines

      public MultiPolylineOptions toPolylines(CompoundCurve compoundCurve)
      Parameters:
      compoundCurve - compound curve
      Returns:
      multi polyline options
    • toCompoundCurve

      public CompoundCurve toCompoundCurve(List<Polyline> polylineList)
      Convert a list of Polyline to a CompoundCurve
      Parameters:
      polylineList - polyline list
      Returns:
      compound curve
    • toCompoundCurve

      public CompoundCurve toCompoundCurve(List<Polyline> polylineList, boolean hasZ, boolean hasM)
      Convert a list of Polyline to a CompoundCurve
      Parameters:
      polylineList - polyline list
      hasZ - has z flag
      hasM - has m flag
      Returns:
      compound curve
    • toCompoundCurveWithOptions

      public CompoundCurve toCompoundCurveWithOptions(MultiPolylineOptions multiPolylineOptions)
      Parameters:
      multiPolylineOptions - multi polyline options
      Returns:
      compound curve
    • toCompoundCurveWithOptions

      public CompoundCurve toCompoundCurveWithOptions(MultiPolylineOptions multiPolylineOptions, boolean hasZ, boolean hasM)
      Parameters:
      multiPolylineOptions - multi polyline options
      hasZ - has z flag
      hasM - has m flag
      Returns:
      compound curve
    • toPolygons

      public MultiPolygonOptions toPolygons(PolyhedralSurface polyhedralSurface)
      Parameters:
      polyhedralSurface - polyhedral surface
      Returns:
      multi polygon options
    • toPolyhedralSurface

      public PolyhedralSurface toPolyhedralSurface(List<Polygon> polygonList)
      Convert a list of Polygon to a PolyhedralSurface
      Parameters:
      polygonList - polygon list
      Returns:
      polyhedral surface
    • toPolyhedralSurface

      public PolyhedralSurface toPolyhedralSurface(List<Polygon> polygonList, boolean hasZ, boolean hasM)
      Convert a list of Polygon to a PolyhedralSurface
      Parameters:
      polygonList - polygon list
      hasZ - has z flag
      hasM - has m flag
      Returns:
      polyhedral surface
    • toPolyhedralSurfaceWithOptions

      public PolyhedralSurface toPolyhedralSurfaceWithOptions(MultiPolygonOptions multiPolygonOptions)
      Parameters:
      multiPolygonOptions - multi polygon options
      Returns:
      polyhedral surface
    • toPolyhedralSurfaceWithOptions

      public PolyhedralSurface toPolyhedralSurfaceWithOptions(MultiPolygonOptions multiPolygonOptions, boolean hasZ, boolean hasM)
      Parameters:
      multiPolygonOptions - multi polygon options
      hasZ - has z flag
      hasM - has m flag
      Returns:
      polyhedral surface
    • toShape

      public GoogleMapShape toShape(Geometry geometry)
      Convert a Geometry to a Map shape
      Parameters:
      geometry - geometry
      Returns:
      google map shape
    • toShapes

      public List<GoogleMapShape> toShapes(GeometryCollection<Geometry> geometryCollection)
      Convert a GeometryCollection to a list of Map shapes
      Parameters:
      geometryCollection - geometry collection
      Returns:
      google map shapes
    • addToMap

      public GoogleMapShape addToMap(GoogleMap map, Geometry geometry)
      Convert a Geometry to a Map shape and add it
      Parameters:
      map - google map
      geometry - geometry
      Returns:
      google map shape
    • addShapeToMap

      public static GoogleMapShape addShapeToMap(GoogleMap map, GoogleMapShape shape)
      Add a shape to the map
      Parameters:
      map - google map
      shape - google map shape
      Returns:
      google map shape
    • addLatLngToMap

      public static Marker addLatLngToMap(GoogleMap map, LatLng latLng)
      Add a LatLng to the map
      Parameters:
      map - google map
      latLng - lat lng
      Returns:
      marker
    • addMarkerOptionsToMap

      public static Marker addMarkerOptionsToMap(GoogleMap map, MarkerOptions options)
      Add MarkerOptions to the map
      Parameters:
      map - google map
      options - marker options
      Returns:
      marker
    • addLatLngToMap

      public static Marker addLatLngToMap(GoogleMap map, LatLng latLng, MarkerOptions options)
      Add a LatLng to the map
      Parameters:
      map - google map
      latLng - lat lng
      options - marker options
      Returns:
      marker
    • addPolylineToMap

      public static Polyline addPolylineToMap(GoogleMap map, PolylineOptions polyline)
      Add a Polyline to the map
      Parameters:
      map - google map
      polyline - polyline options
      Returns:
      polyline
    • addPolygonToMap

      public static Polygon addPolygonToMap(GoogleMap map, PolygonOptions polygon)
      Add a Polygon to the map
      Parameters:
      map - google map
      polygon - polygon options
      Returns:
      polygon
    • addLatLngsToMap

      public static MultiMarker addLatLngsToMap(GoogleMap map, MultiLatLng latLngs)
      Add a list of LatLngs to the map
      Parameters:
      map - google map
      latLngs - lat lngs
      Returns:
      multi marker
    • addPolylinesToMap

      public static MultiPolyline addPolylinesToMap(GoogleMap map, MultiPolylineOptions polylines)
      Add a list of Polylines to the map
      Parameters:
      map - google map
      polylines - multi polyline options
      Returns:
      multi polyline
    • addPolygonsToMap

      public static MultiPolygon addPolygonsToMap(GoogleMap map, MultiPolygonOptions polygons)
      Add a list of Polygons to the map
      Parameters:
      map - google map
      polygons - multi polygon options
      Returns:
      multi polygon
    • addToMap

      public List<GoogleMapShape> addToMap(GoogleMap map, GeometryCollection<Geometry> geometryCollection)
      Convert a GeometryCollection to a list of Map shapes and add to the map
      Parameters:
      map - google map
      geometryCollection - geometry collection
      Returns:
      google map shapes
    • addShapeToMapAsMarkers

      public GoogleMapShapeMarkers addShapeToMapAsMarkers(GoogleMap map, GoogleMapShape shape, MarkerOptions markerOptions, MarkerOptions polylineMarkerOptions, MarkerOptions polygonMarkerOptions, MarkerOptions polygonMarkerHoleOptions, PolylineOptions globalPolylineOptions, PolygonOptions globalPolygonOptions)
      Add a shape to the map as markers
      Parameters:
      map - google map
      shape - google map shape
      markerOptions - marker options
      polylineMarkerOptions - polyline marker options
      polygonMarkerOptions - polygon marker options
      polygonMarkerHoleOptions - polygon marker hole options
      globalPolylineOptions - global polyline options
      globalPolygonOptions - global polygon options
      Returns:
      google map shape markers
    • addPointsToMapAsMarkers

      public List<Marker> addPointsToMapAsMarkers(GoogleMap map, List<LatLng> points, MarkerOptions customMarkerOptions, boolean ignoreIdenticalEnds)
      Add the list of points as markers
      Parameters:
      map - google map
      points - points
      customMarkerOptions - custom marker options
      ignoreIdenticalEnds - ignore identical ends flag
      Returns:
      list of markers
    • addPolylineToMapAsMarkers

      public PolylineMarkers addPolylineToMapAsMarkers(GoogleMap map, PolylineOptions polylineOptions, MarkerOptions polylineMarkerOptions, PolylineOptions globalPolylineOptions)
      Add a Polyline to the map as markers
      Parameters:
      map - google map
      polylineOptions - polyline options
      polylineMarkerOptions - polyline marker options
      globalPolylineOptions - global polyline options
      Returns:
      polyline markers
    • addPolygonToMapAsMarkers

      public PolygonMarkers addPolygonToMapAsMarkers(GoogleMapShapeMarkers shapeMarkers, GoogleMap map, PolygonOptions polygonOptions, MarkerOptions polygonMarkerOptions, MarkerOptions polygonMarkerHoleOptions, PolygonOptions globalPolygonOptions)
      Add a Polygon to the map as markers
      Parameters:
      shapeMarkers - google map shape markers
      map - google map
      polygonOptions - polygon options
      polygonMarkerOptions - polygon marker options
      polygonMarkerHoleOptions - polygon marker hole options
      globalPolygonOptions - global polygon options
      Returns:
      polygon markers
    • addMultiPolylineToMapAsMarkers

      public MultiPolylineMarkers addMultiPolylineToMapAsMarkers(GoogleMapShapeMarkers shapeMarkers, GoogleMap map, MultiPolylineOptions multiPolyline, MarkerOptions polylineMarkerOptions, PolylineOptions globalPolylineOptions)
      Add a MultiPolylineOptions to the map as markers
      Parameters:
      shapeMarkers - google map shape markers
      map - google map
      multiPolyline - multi polyline options
      polylineMarkerOptions - polyline marker options
      globalPolylineOptions - global polyline options
      Returns:
      multi polyline markers
    • addMultiPolygonToMapAsMarkers

      public MultiPolygonMarkers addMultiPolygonToMapAsMarkers(GoogleMapShapeMarkers shapeMarkers, GoogleMap map, MultiPolygonOptions multiPolygon, MarkerOptions polygonMarkerOptions, MarkerOptions polygonMarkerHoleOptions, PolygonOptions globalPolygonOptions)
      Add a MultiPolygonOptions to the map as markers
      Parameters:
      shapeMarkers - google map shape markers
      map - google map
      multiPolygon - multi polygon options
      polygonMarkerOptions - polygon marker options
      polygonMarkerHoleOptions - polygon marker hole options
      globalPolygonOptions - global polygon options
      Returns:
      multi polygon markers
    • getPointsFromMarkers

      public List<LatLng> getPointsFromMarkers(List<Marker> markers)
      Get a list of points as LatLng from a list of Markers
      Parameters:
      markers - list of markers
      Returns:
      lat lngs
    • toGeometry

      public Geometry toGeometry(GoogleMapShape shape)
      Convert a GoogleMapShape to a Geometry
      Parameters:
      shape - google map shape
      Returns:
      geometry
    • boundingBoxToWebMercator

      public BoundingBox boundingBoxToWebMercator(BoundingBox boundingBox)
      Transform the bounding box in the feature projection to web mercator
      Parameters:
      boundingBox - bounding box in feature projection
      Returns:
      bounding box in web mercator
    • boundingBoxToWgs84

      public BoundingBox boundingBoxToWgs84(BoundingBox boundingBox)
      Transform the bounding box in the feature projection to WGS84
      Parameters:
      boundingBox - bounding box in feature projection
      Returns:
      bounding box in WGS84
    • boundingBoxFromWebMercator

      public BoundingBox boundingBoxFromWebMercator(BoundingBox boundingBox)
      Transform the bounding box in web mercator to the feature projection
      Parameters:
      boundingBox - bounding box in web mercator
      Returns:
      bounding box in the feature projection
    • boundingBoxFromWgs84

      public BoundingBox boundingBoxFromWgs84(BoundingBox boundingBox)
      Transform the bounding box in WGS84 to the feature projection
      Parameters:
      boundingBox - bounding box in WGS84
      Returns:
      bounding box in the feature projection