Class DefaultGeography<T>

java.lang.Object
repast.simphony.space.projection.DefaultProjection<T>
repast.simphony.space.gis.DefaultGeography<T>
All Implemented Interfaces:
Geography<T>, Projection<T>
Direct Known Subclasses:
ContextGeography

public class DefaultGeography<T> extends DefaultProjection<T> implements Geography<T>
Default implementation of Geography, a geographic GIS type space.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected GISAdder<T>
     
    protected Map<String,org.geotools.coverage.grid.GridCoverage2D>
     

    Fields inherited from class repast.simphony.space.projection.DefaultProjection

    listeners, name
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a DefaultGeography with the specified name.
    DefaultGeography(String name, String crsCode)
    Creates a DefaultGeography with a specified name and coordindate reference system.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    add(T object)
    Adds an object to this projection without giving it a location.
    void
    addCoverage(String name, org.geotools.coverage.grid.GridCoverage2D coverage)
    Adds the named GridCoverage2D
    boolean
    Evaluate this Projection against the specified Predicate.
    boolean
    Evaluates the Geography against this predicate comparing whether two objects are within a specified distance of each other.
    Gets the current GISAdder that determines how objects are added to the geometry when added to the containing context.
    Gets all the objects that are in this geography.
    org.geotools.coverage.grid.GridCoverage2D
    Gets the named coverage layer
     
    org.opengis.referencing.crs.CoordinateReferenceSystem
    Gets the current coordinate reference system for this geometry.
    org.locationtech.jts.geom.Geometry
    Gets the geometric location of the specified object.
    getLayer(Class clazz)
    Gets the layer for the specified type.
    Gets the named layer.
    Gets the names of the layers in this geography.
    getObjectsWithin(org.locationtech.jts.geom.Envelope envelope)
    Gets an iterable over all the objects within the specified envelope.
    <X> Iterable<X>
    getObjectsWithin(org.locationtech.jts.geom.Envelope envelope, Class<X> type)
    Gets an iterable over all the objects within the specified envelope that are of the specified type and only the specified type.
    javax.measure.Unit<?>
    getUnits(int axis)
    Gets the coordinate reference system's axis units.
    void
    move(T object, org.locationtech.jts.geom.Geometry geom)
    Moves the specified object to the specified location.
    org.locationtech.jts.geom.Geometry
    moveByDisplacement(T object, double lonShift, double latShift)
    Displaces the specified object by the specified lon and lat amount.
    org.locationtech.jts.geom.Geometry
    moveByVector(T object, double distance, double angleInRadians)
    Moves the specified object the specified distance along the specified angle.
    org.locationtech.jts.geom.Geometry
    moveByVector(T object, double distance, javax.measure.Unit<javax.measure.quantity.Length> unit, double angleInRadians)
    Moves the specified object the specified distance along the specified angle.
    queryInexact(org.locationtech.jts.geom.Envelope envelope)
    Queries this geography for objects that MAY intersect the the specified envelope.
    <X> Iterable<X>
    queryInexact(org.locationtech.jts.geom.Envelope envelope, Class<X> type)
    Queries this geography for objects that MAY intersect the the specified envelope and are of the specified type and only the specified type.
    protected void
    remove(T object)
     
    void
     
    void
    Sets the current GISAdder that determines how objects are added to the geometry when added to the containing context.
    void
    setCRS(String crsCode)
    Sets the coordinate reference system for this Geometry.
    void
    setCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
    Sets the coordinate reference system for this Geometry.
    int
    Gets the number of objects in the geography.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface repast.simphony.space.projection.Projection

    addProjectionListener, getName, getProjectionListeners, removeProjectionListener
  • Field Details

    • coverageMap

      protected Map<String,org.geotools.coverage.grid.GridCoverage2D> coverageMap
    • adder

      protected GISAdder<T> adder
  • Constructor Details

    • DefaultGeography

      public DefaultGeography(String name)
      Creates a DefaultGeography with the specified name. The coordinate reference system defaults to WGS84. That CRS uses (longitude, latitude) coordinates with longitude values increasing East and latitude values increasing North. Angular units are degrees and prime meridian is Greenwich..
      Parameters:
      name - the name of the geography
    • DefaultGeography

      public DefaultGeography(String name, String crsCode)
      Creates a DefaultGeography with a specified name and coordindate reference system.
      Parameters:
      name - the name of the geography
      crsCode - the coordinate reference system code (e.g. "EPSG:4326")
  • Method Details

    • getLayerNames

      public Collection<String> getLayerNames()
      Gets the names of the layers in this geography. There will be one layer for each type (by Java class) in a geography.
      Specified by:
      getLayerNames in interface Geography<T>
      Returns:
      the names of the layers in this geography.
    • add

      protected void add(T object)
      Adds an object to this projection without giving it a location.
      Parameters:
      object - the object to add
    • move

      public void move(T object, org.locationtech.jts.geom.Geometry geom)
      Moves the specified object to the specified location. If the location is null then the object remains "in" this projection but without a location. The type of geometry must match the type currently associated with the layer. For example, an object cannot be located at a Point if the layer geometery type is a Polygon. A layer gets its geometry type from the first object that is moved in it.
      Specified by:
      move in interface Geography<T>
      Parameters:
      object - the object to move
      geom - the location to move the object to
    • getLayer

      public Layer getLayer(Class clazz)
      Gets the layer for the specified type.
      Specified by:
      getLayer in interface Geography<T>
      Parameters:
      clazz - the type associated with the desired layer
      Returns:
      the layer for the specified type.
    • getLayer

      public Layer getLayer(String name)
      Gets the named layer.
      Specified by:
      getLayer in interface Geography<T>
      Parameters:
      name - the layer name
      Returns:
      the named Layer.
    • getGeometry

      public org.locationtech.jts.geom.Geometry getGeometry(Object object)
      Gets the geometric location of the specified object.
      Specified by:
      getGeometry in interface Geography<T>
      Parameters:
      object - the object
      Returns:
      the geometric location of the specified object.
    • getObjectsWithin

      public Iterable<T> getObjectsWithin(org.locationtech.jts.geom.Envelope envelope)
      Gets an iterable over all the objects within the specified envelope.
      Specified by:
      getObjectsWithin in interface Geography<T>
      Parameters:
      envelope - the bounding envelope
      Returns:
      an iterable over all the objects within the specified location.
    • queryInexact

      public Iterable<T> queryInexact(org.locationtech.jts.geom.Envelope envelope)
      Queries this geography for objects that MAY intersect the the specified envelope. This provides a first level filter for range rectangle queries. A second level filter SHOULD be applied to test for exact intersection.
      Specified by:
      queryInexact in interface Geography<T>
      Parameters:
      envelope - the envelope to query for
      Returns:
      an iterable over items whose extents MAY intersect the given search envelope.
    • getObjectsWithin

      public <X> Iterable<X> getObjectsWithin(org.locationtech.jts.geom.Envelope envelope, Class<X> type)
      Gets an iterable over all the objects within the specified envelope that are of the specified type and only the specified type. Subclasses are excluded.
      Specified by:
      getObjectsWithin in interface Geography<T>
      Parameters:
      envelope - the bounding envelope
      type - the type of objects to return
      Returns:
      an iterable over all the objects within the specified location.
    • queryInexact

      public <X> Iterable<X> queryInexact(org.locationtech.jts.geom.Envelope envelope, Class<X> type)
      Queries this geography for objects that MAY intersect the the specified envelope and are of the specified type and only the specified type. Subclasses are excluded.This provides a first level filter for range rectangle queries. A second level filter SHOULD be applied to test for exact intersection.
      Specified by:
      queryInexact in interface Geography<T>
      Parameters:
      envelope - the envelope to query for
      type - the type of objects to return
      Returns:
      an iterable over items whose extents MAY intersect the given search envelope.
    • getAllObjects

      public Iterable<T> getAllObjects()
      Gets all the objects that are in this geography.
      Specified by:
      getAllObjects in interface Geography<T>
      Returns:
      an iterable over all the objects in this geography.
    • size

      public int size()
      Gets the number of objects in the geography.
      Specified by:
      size in interface Geography<T>
      Returns:
      the number of objects in the geography
    • setCRS

      public void setCRS(String crsCode)
      Sets the coordinate reference system for this Geometry. For example, "EPSG:4326". All the locations of the objects in this Geometry will be appropriately transformed.
      Specified by:
      setCRS in interface Geography<T>
      Parameters:
      crsCode - the coordinate reference system code
    • setCRS

      public void setCRS(org.opengis.referencing.crs.CoordinateReferenceSystem crs)
      Sets the coordinate reference system for this Geometry. All the locations of the objects in this Geometry will be appropriately transformed.
      Specified by:
      setCRS in interface Geography<T>
      Parameters:
      crs - the coordinate reference system
    • moveByVector

      public org.locationtech.jts.geom.Geometry moveByVector(T object, double distance, double angleInRadians)
      Moves the specified object the specified distance along the specified angle.
      Specified by:
      moveByVector in interface Geography<T>
      Parameters:
      object - the object to move
      distance - the distance to move in meters
      angleInRadians - the angle along which to move. This USES standard mathematical axes where 90 degrees points "north".
      Returns:
      the geometric location the object was moved to
    • moveByVector

      public org.locationtech.jts.geom.Geometry moveByVector(T object, double distance, javax.measure.Unit<javax.measure.quantity.Length> unit, double angleInRadians)
      Moves the specified object the specified distance along the specified angle.
      Specified by:
      moveByVector in interface Geography<T>
      Parameters:
      object - the object to move
      distance - the distance to move
      unit - the distance units. This must be convertable to meters
      angleInRadians - the angle along which to move
      Returns:
      the geometric location the object was moved to
    • moveByDisplacement

      public org.locationtech.jts.geom.Geometry moveByDisplacement(T object, double lonShift, double latShift)
      Displaces the specified object by the specified lon and lat amount.
      Specified by:
      moveByDisplacement in interface Geography<T>
      Parameters:
      object - the object to move
      lonShift - the amount to move longitudinaly
      latShift - the amount to move latitudinaly
      Returns:
      the new geometry of the object
    • getCRS

      public org.opengis.referencing.crs.CoordinateReferenceSystem getCRS()
      Gets the current coordinate reference system for this geometry.
      Specified by:
      getCRS in interface Geography<T>
      Returns:
      the current coordinate reference system for this geometry.
    • remove

      protected void remove(T object)
    • getAdder

      public GISAdder<T> getAdder()
      Gets the current GISAdder that determines how objects are added to the geometry when added to the containing context.
      Specified by:
      getAdder in interface Geography<T>
      Returns:
      the current GISAdder
    • setAdder

      public void setAdder(GISAdder<T> adder)
      Sets the current GISAdder that determines how objects are added to the geometry when added to the containing context.
      Specified by:
      setAdder in interface Geography<T>
      Parameters:
      adder - the new GISAdder
    • getUnits

      public javax.measure.Unit<?> getUnits(int axis)
      Gets the coordinate reference system's axis units.
      Specified by:
      getUnits in interface Geography<T>
      Parameters:
      axis - the axis index.
      Returns:
      the coordinate reference system's axis units.
    • evaluate

      public boolean evaluate(ProjectionPredicate predicate)
      Evaluate this Projection against the specified Predicate. DefaultGeography provides doesn't call predicate.evaluate() but rather checks the predicate type and evaluates appropriately here. This is because the Geography interface is not available to repast.simphony.space.projection.ProjectionPredicate.
      Specified by:
      evaluate in interface Projection<T>
      Overrides:
      evaluate in class DefaultProjection<T>
      Parameters:
      predicate -
      Returns:
      true if the predicate evaluates to true, otherwise false. False can also mean that the predicate is not applicable to this Projection. For example, a linked type predicate evaluated against a grid projection.
    • evaluateWithin

      public boolean evaluateWithin(Within within)
      Evaluates the Geography against this predicate comparing whether two objects are within a specified distance of each other. The distance is orthodromic and in meters. Note that for Polygons the distance is measured from the center and not from the nearest point.
      Parameters:
      geography - the geography to evaluate against.
      Returns:
      true if this predicate is true for the specified projection otherwise false.
    • getCoverage

      public org.geotools.coverage.grid.GridCoverage2D getCoverage(String name)
      Description copied from interface: Geography
      Gets the named coverage layer
      Specified by:
      getCoverage in interface Geography<T>
      Parameters:
      name - the layer name
      Returns:
      the named coverage
    • addCoverage

      public void addCoverage(String name, org.geotools.coverage.grid.GridCoverage2D coverage)
      Description copied from interface: Geography
      Adds the named GridCoverage2D
      Specified by:
      addCoverage in interface Geography<T>
    • removeCoverage

      public void removeCoverage(String name)
      Specified by:
      removeCoverage in interface Geography<T>
    • getCoverageNames

      public Collection<String> getCoverageNames()
      Specified by:
      getCoverageNames in interface Geography<T>