RePast
v. 2.0

uchicago.src.sim.gis
Class LineStringAdapter

java.lang.Object
  |
  +--uchicago.src.sim.network.DefaultEdge
        |
        +--uchicago.src.sim.gis.LineStringAdapter
All Implemented Interfaces:
Edge, RepastGisFeature
Direct Known Subclasses:
DrawableLineString

public class LineStringAdapter
extends DefaultEdge
implements RepastGisFeature

This is an adapter between a geotools LineString, a JTS LineString and a Repast Edge. It contains all of the good bits from each of those.


Field Summary
protected  Hashtable attributes
           
protected  com.vividsolutions.jts.geom.Geometry geometry
           
protected  boolean multi
           
protected  LinePoint[] points
           
 
Fields inherited from class uchicago.src.sim.network.DefaultEdge
from, label, strength, to, type
 
Constructor Summary
LineStringAdapter(org.geotools.feature.Feature f)
          Create a LineString adapter from a Geotools feature.
LineStringAdapter(com.vividsolutions.jts.geom.Geometry geo, Hashtable attr)
          Create a lineStringAdapter from a geometry (linestring) and an attributes table.
LineStringAdapter(SpatialNode from, SpatialNode to)
          Create a lineString from two spatial nodes.
 
Method Summary
 void addAttribute(String key, Object value)
          add another attribute to this feature.
 boolean crosses(RepastGisFeature g)
          Defined in the openGis SimpleFeatureSpecification.
 boolean disjoint(RepastGisFeature g)
          Defined in the openGis SimpleFeatureSpecification.
 Object getAttribute(String key)
          get an attribute from this feature.
 String[] getAttributeNames()
          returns a list of the names of the attributes for this feature.
 com.vividsolutions.jts.geom.Geometry getGeometry()
          Gets the geometry that defines this feature.
 double getLength()
          Calculates the distance of the linestring.
 boolean intersects(RepastGisFeature g)
          Defined in the openGis SimpleFeatureSpecification.
 boolean isMulti()
          Returns true if the feature is a "multi" type.
 boolean overlaps(RepastGisFeature g)
          Defined in the openGis SimpleFeatureSpecification.
 void setAttributes(Hashtable attr)
          set the attribute table for this feature.
 void setFeature(org.geotools.feature.Feature f)
          Set the gis feature.
 void setGeometry(com.vividsolutions.jts.geom.Geometry geo)
          set the geometry for this feature.
 boolean touches(RepastGisFeature g)
          Defined in the openGis SimpleFeatureSpecification.
 boolean within(RepastGisFeature g)
          Defined in the openGis SimpleFeatureSpecification.
 
Methods inherited from class uchicago.src.sim.network.DefaultEdge
getFrom, getLabel, getStrength, getTo, getType, setFrom, setLabel, setStrength, setTo, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

attributes

protected Hashtable attributes

geometry

protected com.vividsolutions.jts.geom.Geometry geometry

points

protected LinePoint[] points

multi

protected boolean multi
Constructor Detail

LineStringAdapter

public LineStringAdapter(SpatialNode from,
                         SpatialNode to)
Create a lineString from two spatial nodes. In reality most times one will be creating these from a datasource, but if ever the need should arise, this will work also.

Parameters:
from -
to -

LineStringAdapter

public LineStringAdapter(org.geotools.feature.Feature f)
                  throws Exception
Create a LineString adapter from a Geotools feature. This will be the most common way of creating a LineStringAdapter

Parameters:
f -
Throws:
Exception

LineStringAdapter

public LineStringAdapter(com.vividsolutions.jts.geom.Geometry geo,
                         Hashtable attr)
                  throws Exception
Create a lineStringAdapter from a geometry (linestring) and an attributes table.

Parameters:
geo -
attr -
Method Detail

getLength

public double getLength()
Calculates the distance of the linestring.

Returns:

setGeometry

public void setGeometry(com.vividsolutions.jts.geom.Geometry geo)
                 throws IllegalArgumentException
set the geometry for this feature.

Specified by:
setGeometry in interface RepastGisFeature
Parameters:
geo -
Throws:
IllegalArgumentException

setFeature

public void setFeature(org.geotools.feature.Feature f)
                throws Exception
Description copied from interface: RepastGisFeature
Set the gis feature. This feature includes both the geometry data and the attributes.

Specified by:
setFeature in interface RepastGisFeature
Parameters:
f - The feature to be added
Throws:
Exception - throws an exception if this is not a proper feature.

setAttributes

public void setAttributes(Hashtable attr)
set the attribute table for this feature.

Specified by:
setAttributes in interface RepastGisFeature
Parameters:
attr -

getAttributeNames

public String[] getAttributeNames()
returns a list of the names of the attributes for this feature.

Specified by:
getAttributeNames in interface RepastGisFeature
Returns:

addAttribute

public void addAttribute(String key,
                         Object value)
add another attribute to this feature.

Specified by:
addAttribute in interface RepastGisFeature
Parameters:
key -
value -

getAttribute

public Object getAttribute(String key)
get an attribute from this feature.

Specified by:
getAttribute in interface RepastGisFeature
Parameters:
key -
Returns:

getGeometry

public com.vividsolutions.jts.geom.Geometry getGeometry()
Description copied from interface: RepastGisFeature
Gets the geometry that defines this feature.

Specified by:
getGeometry in interface RepastGisFeature
Returns:

isMulti

public boolean isMulti()
Returns true if the feature is a "multi" type.

Specified by:
isMulti in interface RepastGisFeature
Returns:
multi

intersects

public boolean intersects(RepastGisFeature g)
Defined in the openGis SimpleFeatureSpecification.

Specified by:
intersects in interface RepastGisFeature
Parameters:
g -
Returns:

touches

public boolean touches(RepastGisFeature g)
Defined in the openGis SimpleFeatureSpecification.

Specified by:
touches in interface RepastGisFeature
Parameters:
g -
Returns:

within

public boolean within(RepastGisFeature g)
Defined in the openGis SimpleFeatureSpecification.

Specified by:
within in interface RepastGisFeature
Parameters:
g -
Returns:

crosses

public boolean crosses(RepastGisFeature g)
Defined in the openGis SimpleFeatureSpecification.

Specified by:
crosses in interface RepastGisFeature
Parameters:
g -
Returns:

overlaps

public boolean overlaps(RepastGisFeature g)
Defined in the openGis SimpleFeatureSpecification.

Specified by:
overlaps in interface RepastGisFeature
Parameters:
g -
Returns:

disjoint

public boolean disjoint(RepastGisFeature g)
Defined in the openGis SimpleFeatureSpecification.

Specified by:
disjoint in interface RepastGisFeature
Parameters:
g -
Returns:

RePast
v. 2.0

Bug reports and feature requests to RePast