repast.simphony.space.gis
Class ShapefileLoader<T>

java.lang.Object
  extended by 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

Constructor Summary
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.
 
Method Summary
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 class
shapefile - the shapefile that serves as the datasource for the agent properties
geography - the geography to hold spatial locations of the agents
context - 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.