Package repast.simphony.space.gis
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>
adder
protected Map<String,org.geotools.coverage.grid.GridCoverage2D>
coverageMap
-
Fields inherited from class repast.simphony.space.projection.DefaultProjection
listeners, name
-
-
Constructor Summary
Constructors Constructor Description DefaultGeography(String name)
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
All Methods Instance Methods Concrete Methods 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 GridCoverage2Dboolean
evaluate(ProjectionPredicate predicate)
Evaluate this Projection against the specified Predicate.boolean
evaluateWithin(Within within)
Evaluates the Geography against this predicate comparing whether two objects are within a specified distance of each other.GISAdder<T>
getAdder()
Gets the current GISAdder that determines how objects are added to the geometry when added to the containing context.Iterable<T>
getAllObjects()
Gets all the objects that are in this geography.org.geotools.coverage.grid.GridCoverage2D
getCoverage(String name)
Gets the named coverage layerCollection<String>
getCoverageNames()
org.opengis.referencing.crs.CoordinateReferenceSystem
getCRS()
Gets the current coordinate reference system for this geometry.org.locationtech.jts.geom.Geometry
getGeometry(Object object)
Gets the geometric location of the specified object.Layer
getLayer(Class clazz)
Gets the layer for the specified type.Layer
getLayer(String name)
Gets the named layer.Collection<String>
getLayerNames()
Gets the names of the layers in this geography.Iterable<T>
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.Iterable<T>
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
removeCoverage(String name)
void
setAdder(GISAdder<T> adder)
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
size()
Gets the number of objects in the geography.-
Methods inherited from class repast.simphony.space.projection.DefaultProjection
addProjectionListener, fireProjectionEvent, getName, getProjectionListeners, removeProjectionListener
-
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
-
-
-
-
Constructor Detail
-
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
-
-
Method Detail
-
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 interfaceGeography<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.
-
getGeometry
public org.locationtech.jts.geom.Geometry getGeometry(Object object)
Gets the geometric location of the specified object.- Specified by:
getGeometry
in interfaceGeography<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 interfaceGeography<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 interfaceGeography<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 interfaceGeography<T>
- Parameters:
envelope
- the bounding envelopetype
- 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 interfaceGeography<T>
- Parameters:
envelope
- the envelope to query fortype
- 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 interfaceGeography<T>
- Returns:
- an iterable over all the objects in this geography.
-
size
public int size()
Gets 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.
-
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.
-
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 interfaceGeography<T>
- Parameters:
object
- the object to movedistance
- the distance to move in metersangleInRadians
- 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 interfaceGeography<T>
- Parameters:
object
- the object to movedistance
- the distance to moveunit
- the distance units. This must be convertable to metersangleInRadians
- 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 interfaceGeography<T>
- Parameters:
object
- the object to movelonShift
- the amount to move longitudinalylatShift
- 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.
-
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.
-
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.
-
getUnits
public javax.measure.Unit<?> getUnits(int axis)
Gets 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 interfaceProjection<T>
- Overrides:
evaluate
in classDefaultProjection<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 interfaceGeography<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 interfaceGeography<T>
-
removeCoverage
public void removeCoverage(String name)
- Specified by:
removeCoverage
in interfaceGeography<T>
-
getCoverageNames
public Collection<String> getCoverageNames()
- Specified by:
getCoverageNames
in interfaceGeography<T>
-
-