/repast.simphony/tags/RS-2.0b/repast.simphony.core/src/repast/simphony/space/gis/Geography.java

# · Java · 224 lines · 34 code · 26 blank · 164 comment · 0 complexity · fffde6a99c01f6e60a733bd6061392f7 MD5 · raw file

  1. /**
  2. *
  3. */
  4. package repast.simphony.space.gis;
  5. import com.vividsolutions.jts.geom.Envelope;
  6. import com.vividsolutions.jts.geom.Geometry;
  7. import org.opengis.referencing.crs.CoordinateReferenceSystem;
  8. import repast.simphony.space.projection.Projection;
  9. import repast.simphony.space.projection.ProjectionPredicate;
  10. import javax.units.Unit;
  11. import java.util.Collection;
  12. /**
  13. * Space that locates objects in a geographic gis-type space.
  14. *
  15. * @param <T> Object type contained by the geography.
  16. */
  17. public interface Geography<T> extends Projection<T> {
  18. /**
  19. * Gets the names of the layers in this geography. There will be one layer
  20. * for each type (by Java class) in a geography.
  21. *
  22. * @return the names of the layers in this geography.
  23. */
  24. Collection<String> getLayerNames();
  25. /**
  26. * Moves the specified object to the specified location. If the location
  27. * is null then the object remains "in" this projection but without
  28. * a location. The type of geometry must match the type currently associated
  29. * with the layer. For example, an object cannot be located at a Point if
  30. * the layer geometery type is a Polygon. A layer gets its geometry type
  31. * from the first object that is moved in it.
  32. *
  33. * @param object the object to move
  34. * @param geom the location to move the object to
  35. */
  36. void move(T object, Geometry geom);
  37. /**
  38. * Gets the layer for the specified type.
  39. *
  40. * @param clazz the type associated with the desired layer
  41. * @return the layer for the specified type.
  42. */
  43. Layer getLayer(Class clazz);
  44. /**
  45. * Gets the named layer.
  46. *
  47. * @param name the layer name
  48. * @return the named Layer.
  49. */
  50. Layer getLayer(String name);
  51. /**
  52. * Gets the geometric location of the specified object.
  53. *
  54. * @param object the object
  55. * @return the geometric location of the specified object.
  56. */
  57. Geometry getGeometry(Object object);
  58. /**
  59. * Gets an iterable over all the objects within the specified envelope.
  60. *
  61. * @param envelope the bounding envelope
  62. * @return an iterable over all the objects within the specified location.
  63. */
  64. Iterable<T> getObjectsWithin(Envelope envelope);
  65. /**
  66. * Queries this geography for objects that MAY intersect the
  67. * the specified envelope. This provides a first level
  68. * filter for range rectangle queries. A second level
  69. * filter SHOULD be applied to test for exact intersection.
  70. *
  71. * @param envelope the envelope to query for
  72. * @return an iterable over items whose extents MAY intersect the
  73. * given search envelope.
  74. */
  75. Iterable<T> queryInexact(Envelope envelope);
  76. /**
  77. * Sets the coordinate reference system for this Geometry. For example,
  78. * "EPSG:4326". All the locations of the objects in this Geometry will be
  79. * appropriately transformed.
  80. *
  81. * @param crsCode the coordinate reference system code
  82. */
  83. void setCRS(String crsCode);
  84. /**
  85. * Sets the coordinate reference system for this Geometry. All
  86. * the locations of the objects in this Geometry will be
  87. * appropriately transformed.
  88. *
  89. * @param crs the coordinate reference system
  90. */
  91. void setCRS(CoordinateReferenceSystem crs);
  92. /**
  93. * Moves the specified object the specified distance along the specified angle.
  94. *
  95. * @param object the object to move
  96. * @param distance the distance to move in meters
  97. * @param angleInRadians the angle along which to move
  98. * @return the geometric location the object was moved to
  99. */
  100. Geometry moveByVector(T object, double distance,
  101. double angleInRadians);
  102. /**
  103. * Moves the specified object the specified distance along the specified angle.
  104. *
  105. * @param object the object to move
  106. * @param distance the distance to move
  107. * @param unit the distance units. This must be convertable to meters
  108. * @param angleInRadians the angle along which to move
  109. * @return the geometric location the object was moved to
  110. */
  111. Geometry moveByVector(T object, double distance, Unit unit,
  112. double angleInRadians);
  113. /**
  114. * Displaces the specified object by the specified lon and lat amount.
  115. *
  116. * @param object the object to move
  117. * @param lonShift the amount to move longitudinaly
  118. * @param latShift the amount to move latitudinaly
  119. * @return the new geometry of the object
  120. */
  121. Geometry moveByDisplacement(T object, double lonShift,
  122. double latShift);
  123. /**
  124. * Gets the current coordinate reference system for this geometry.
  125. *
  126. * @return the current coordinate reference system for this geometry.
  127. */
  128. CoordinateReferenceSystem getCRS();
  129. /**
  130. * Gets the current GISAdder that determines how objects are added to the
  131. * geometry when added to the containing context.
  132. *
  133. * @return the current GISAdder
  134. */
  135. GISAdder<T> getAdder();
  136. /**
  137. * Sets the current GISAdder that determines how objects are added to the
  138. * geometry when added to the containing context.
  139. *
  140. * @param adder the new GISAdder
  141. */
  142. void setAdder(GISAdder<T> adder);
  143. /**
  144. * Gets the coordinate reference system's axis units.
  145. *
  146. * @param axis the axis index.
  147. * @return the coordinate reference system's axis units.
  148. */
  149. Unit getUnits(int axis);
  150. /**
  151. * Evaluate this Projection against the specified Predicate. This typically
  152. * involves a double dispatch where the Projection calls back to the
  153. * predicate, passing itself.
  154. *
  155. * @param predicate
  156. * @return true if the predicate evaluates to true, otherwise false. False
  157. * can also mean that the predicate is not applicable to this
  158. * Projection. For example, a linked type predicate evaluated
  159. * against a grid projection.
  160. */
  161. // @Override
  162. boolean evaluate(ProjectionPredicate predicate);
  163. /**
  164. * Gets an iterable over all the objects within the specified envelope
  165. * that are of the specified type and only the specified type. Subclasses
  166. * are excluded.
  167. *
  168. * @param envelope the bounding envelope
  169. * @param type the type of objects to return
  170. * @return an iterable over all the objects within the specified location.
  171. */
  172. <X> Iterable<X> getObjectsWithin(Envelope envelope, Class<X> type);
  173. /**
  174. * Queries this geography for objects that MAY intersect the
  175. * the specified envelope and are of the specified type and only the specified type.
  176. * Subclasses are excluded.This provides a first level
  177. * filter for range rectangle queries. A second level
  178. * filter SHOULD be applied to test for exact intersection.
  179. *
  180. * @param envelope the envelope to query for
  181. * @param type the type of objects to return
  182. * @return an iterable over items whose extents MAY intersect the
  183. * given search envelope.
  184. */
  185. <X> Iterable<X> queryInexact(Envelope envelope, Class<X> type);
  186. /**
  187. * Gets all the objects that are in this geography.
  188. *
  189. * @return an iterable over all the objects in this geography.
  190. */
  191. Iterable<T> getAllObjects();
  192. /**
  193. * Gets the number of objects in the geography.
  194. *
  195. * @return the number of objects in the geography
  196. */
  197. int size();
  198. }