Package repast.simphony.space.gis
Class ShapefileLoader<T>
- java.lang.Object
-
- repast.simphony.space.gis.ShapefileLoader<T>
-
public class ShapefileLoader<T> extends Object
Creates and sets agents properties from a features in shapefile.- Author:
- Nick Collier
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
Returns true if there are more features left to process, otherwise false.void
load()
Creates all the agents for the shapefile features, setting each agent's properteis to the value of a feature's relevant attributes.T
next()
Creates the next agent from the next feature in the shapefile, setting that agent's properties to the value of that feature's relevant attributes.T
next(T obj)
Sets the specified object's properties to the relevant attributes values of the next feature.T
nextWithArgs(Object... constructorArgs)
Creates the next agent from the next feature in the shapefile, setting that agent's properties to the value of that feature's relevant attributes.
-
-
-
Constructor Detail
-
ShapefileLoader
public ShapefileLoader(Class<T> clazz, URL shapefile, Geography geography, Context context)
Creates a shapefile loader for agents of the specified class and whose data source is the specified shapefile. The agents will be placed into the specified Geography according to the geometry specified in the shapefile and transformed according to the geography's CRS.- Parameters:
clazz
- the agent classshapefile
- the shapefile that serves as the datasource for the agent propertiesgeography
- the geography to hold spatial locations of the agentscontext
- the context to add the agents to
-
-
Method Detail
-
load
public void load()
Creates all the agents for the shapefile features, setting each agent's properteis to the value of a feature's relevant attributes.
-
next
public T next()
Creates the next agent from the next feature in the shapefile, setting that agent's properties to the value of that feature's relevant attributes.- Returns:
- the created agent
-
nextWithArgs
public T nextWithArgs(Object... constructorArgs) throws IllegalArgumentException
Creates the next agent from the next feature in the shapefile, setting that agent's properties to the value of that feature's relevant attributes. Note that the constructor matching is somewhat naive and looks for exact matches.- Parameters:
constructorArgs
- parameters to pass to the constructor when creating the agent.- Returns:
- the created agent
- Throws:
IllegalArgumentException
- if the constructor args don't match a constructor.
-
next
public T next(T obj)
Sets the specified object's properties to the relevant attributes values of the next feature.- Parameters:
obj
- the object whose properties we want to set.- Returns:
- the object with is properties now set.
-
hasNext
public boolean hasNext()
Returns true if there are more features left to process, otherwise false.- Returns:
- true if there are more features left to process, otherwise false.
-
-