anl.repast.gis.data
Class OpenMapData

java.lang.Object
  extended byanl.repast.gis.data.OpenMapData

public class OpenMapData
extends java.lang.Object

Author:
Robert Najlis

Field Summary
(package private)  com.bbn.openmap.gui.OpenMapFrame frame
           
private static OpenMapData instance
           
(package private)  com.bbn.openmap.MapBean mapBean
           
(package private)  com.bbn.openmap.MapHandler mapHandler
           
(package private)  com.bbn.openmap.gui.BasicMapPanel mapPanel
           
(package private)  com.bbn.openmap.layer.shape.ShapeLayer shapeLayer
           
static int SHP_POINT
           
static int SHP_POLYGON
           
static int SHP_POLYLINE
           
 
Constructor Summary
OpenMapData()
           
 
Method Summary
 com.bbn.openmap.dataAccess.shape.EsriGraphicList buildEsriGraphicList(java.util.Collection gisAgents)
          Takes a Collection of GisAgents, gets the OMGraphic from each, and attempts to build an EsriGraphicList from them.
 com.bbn.openmap.dataAccess.shape.EsriGraphicList buildEsriGraphicList(java.util.Collection gisAgents, int shpType)
          Takes a Collection of GisAgents, gets the OMGraphic from each, and attempts to build an EsriGraphicList from them.
 anl.repast.gis.data.FeatureArrayList buildFeatureArrayList(java.util.Collection gisAgents, java.lang.String datasource)
          helper function for writeAgents takes a Collection of GisAgents and a datasource and creates a FeatureArrayList to store the features
 java.util.ArrayList createAgents(java.lang.Class clazz, java.lang.String datasource)
          Create a list of GisAgents given a class type that implements the GisInterface, and a Shapefile datasource
 double getArea(com.bbn.openmap.dataAccess.shape.EsriGraphic esriGraphic)
          Gets the area for an EsriGraphic using the com.bbn.openmap.geo.Geo class
 double getArea(com.bbn.openmap.omGraphics.OMGraphic omGraphic)
          Gets the area for an OMGraphic using the com.bbn.openmap.geo.Geo class
 int getAttributePosition(java.lang.String name, org.geotools.feature.FeatureType ft)
          given the feature type and the name, get the Attribute Position
 java.util.HashSet getAttributeValues(java.lang.String attributeName, java.lang.String dataSource)
          for a given attribute in a datasource (.shp file) gets a set of all the attribute's values
 com.bbn.openmap.LatLonPoint getCenter(com.bbn.openmap.dataAccess.shape.EsriGraphic eg)
          gets the center of the extents of the EsriGraphic
 com.bbn.openmap.LatLonPoint getCenter(com.bbn.openmap.dataAccess.shape.EsriGraphicList egList)
          gets the center of the extents of the EsriGraphicList
 com.bbn.openmap.LatLonPoint getCenter(float[] extents)
          gets the center of the extents
 com.bbn.openmap.LatLonPoint getCenter(anl.repast.gis.OpenMapAgent omd)
          gets the center of the extents of the OMGraphic Requires that the OMGraphic is an instance of EsriGraphic
 com.bbn.openmap.LatLonPoint getCenter(java.lang.String datasource)
          gets the center of the extents of the datasource Requires that the datasource is a Shapefile
 com.bbn.openmap.plugin.esri.EsriLayer getEsriLayer(java.lang.String datasource)
          given a shapefile, returns an OpenMap EsriLayer
 float[] getExtents(com.bbn.openmap.dataAccess.shape.EsriGraphicList egList)
          gets the extents for an EsriGraphicList The lat/lon extent of the EsriGraphicList contents, returned as miny, minx, maxy maxx in order of the array.
 float[] getExtents(com.bbn.openmap.omGraphics.OMGraphic omg)
          gets the extents for an OMGraphic The lat/lon extent of the EsriGraphic contents, returned as miny, minx, maxy maxx in order of the array.
 float[] getExtents(java.lang.String datasource)
          gets the extents for a shapefile The lat/lon extent of the EsriGraphicList contents, returned as miny, minx, maxy maxx in order of the array.
 java.lang.reflect.Method getGetMethodForAttributeType(java.lang.Class clazz, org.geotools.feature.AttributeType at)
          helper function given an Attribute type (generally from a Shapefile's dbf file) get the related get method
 java.lang.reflect.Method getGetMethodForName(java.lang.Class clazz, java.lang.String name)
          helper function given an Column name (generally from a Shapefile's dbf file) get the related get method
static OpenMapData getInstance()
           
 java.lang.reflect.Method getSetMethodForAttributeType(java.lang.Class clazz, org.geotools.feature.AttributeType at)
          helper function given an Attribute type (generally from a Shapefile's dbf file) get the related set method
 java.lang.reflect.Method getSetMethodForName(java.lang.Class clazz, java.lang.String columnName)
          helper function given an Column name (generally from a Shapefile's dbf file) get the related set method
 int getShpType(java.lang.String datasource)
           
 anl.repast.gis.data.FieldNameAndType[] interrogate(java.lang.String datasource)
          Looks into a Shapefile and returns an array of FieldNameAndType objects which show the names and types of fields in the Shapefile's dbf file
 void readNeighborhoodInfo(java.lang.String neighborhoodFile, java.util.ArrayList gisAgents)
          Reads in a file in the .GAL format created from GEODA Geoda can give a list of neighbors for GIS data
 java.util.Collection sortGisAgentsbyIndex(java.util.Collection gisAgents)
          Sorts a Collection of GisAgents using the GisAgent's getGisAgentIndex function
 java.util.ArrayList updateAgentsFromShapefile(java.lang.Class clazz, java.util.ArrayList agentList, java.lang.String datasource)
          Update a list of GisAgents from a Shapefile In case you have already created GisAgents, but want to update them from a Shapefile
 void writeAgents(java.util.Collection agents, java.lang.String datasource)
          write agents to the specified datasource datasource should end with .shp.
 void writeAgents(java.util.Collection gisAgents, java.lang.String origDatasource, java.lang.String newDatasource)
          write agents to the specified datasource datasource should end with .shp.
 void writeAgentsNoShp(java.util.Collection gisAgents, com.bbn.openmap.proj.Projection proj, java.lang.String datasource)
          Writes agents created from OpenMap to a Shapefile (.shp, .dbf and .shx).
 java.util.ArrayList writeDbfFromAgents(java.util.Collection gisAgents, java.lang.String datasource)
          helper function for writeAgentsNoShp writes the dbf file from a list of GisAgents
 void writeFeatureArrayListToDbf(java.util.Collection gisAgents, anl.repast.gis.data.FeatureArrayList featureList, java.lang.String origDatasource, java.lang.String newDatasource)
          helper function for writeAgents takes the FeatueArrayList and writes it to a dbf file
 void writeShpUsingShp(java.util.Collection gisAgents, java.lang.String origDatasource, java.lang.String newDatasource)
          A helper function for the writeAgents function
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

frame

com.bbn.openmap.gui.OpenMapFrame frame

mapPanel

com.bbn.openmap.gui.BasicMapPanel mapPanel

mapBean

com.bbn.openmap.MapBean mapBean

mapHandler

com.bbn.openmap.MapHandler mapHandler

shapeLayer

com.bbn.openmap.layer.shape.ShapeLayer shapeLayer

SHP_POINT

public static final int SHP_POINT
See Also:
Constant Field Values

SHP_POLYLINE

public static final int SHP_POLYLINE
See Also:
Constant Field Values

SHP_POLYGON

public static final int SHP_POLYGON
See Also:
Constant Field Values

instance

private static OpenMapData instance
Constructor Detail

OpenMapData

public OpenMapData()
Method Detail

getInstance

public static OpenMapData getInstance()

readNeighborhoodInfo

public void readNeighborhoodInfo(java.lang.String neighborhoodFile,
                                 java.util.ArrayList gisAgents)
Reads in a file in the .GAL format created from GEODA Geoda can give a list of neighbors for GIS data

Parameters:
neighborhoodFile -
gisAgents - - a list of agents that implement the GisAgetn interface

createAgents

public java.util.ArrayList createAgents(java.lang.Class clazz,
                                        java.lang.String datasource)
Create a list of GisAgents given a class type that implements the GisInterface, and a Shapefile datasource

Parameters:
clazz -
datasource -
Returns:
ArrayList of GisAgents

updateAgentsFromShapefile

public java.util.ArrayList updateAgentsFromShapefile(java.lang.Class clazz,
                                                     java.util.ArrayList agentList,
                                                     java.lang.String datasource)
Update a list of GisAgents from a Shapefile In case you have already created GisAgents, but want to update them from a Shapefile

Parameters:
clazz -
agentList -
datasource -
Returns:

interrogate

public anl.repast.gis.data.FieldNameAndType[] interrogate(java.lang.String datasource)
                                                   throws java.io.IOException
Looks into a Shapefile and returns an array of FieldNameAndType objects which show the names and types of fields in the Shapefile's dbf file

Parameters:
datasource -
Returns:
Throws:
java.io.IOException

sortGisAgentsbyIndex

public java.util.Collection sortGisAgentsbyIndex(java.util.Collection gisAgents)
Sorts a Collection of GisAgents using the GisAgent's getGisAgentIndex function

Parameters:
gisAgents -
Returns:

writeAgents

public void writeAgents(java.util.Collection agents,
                        java.lang.String datasource)
write agents to the specified datasource datasource should end with .shp. Writes the .shp, .dbf and .shx files Reads in the data from the shapefile, overwrites the original Shapefile data with data from the GisAgent In order to overwrite Shapefile data with GisAgent data, the GisAgent must implement a setDbfField() function where DbfField is the name of field in the .dbf file associated with the Shapefile Note: this version of the function will overwrite the original data. To prevent this use the version of this function which takes two datasource parameters

Parameters:
agents -
datasource -

writeAgents

public void writeAgents(java.util.Collection gisAgents,
                        java.lang.String origDatasource,
                        java.lang.String newDatasource)
write agents to the specified datasource datasource should end with .shp. Writes the .shp, .dbf and .shx files Reads in the data from the shapefile, overwrites the original Shapefile data with data from the GisAgent In order to overwrite Shapefile data with GisAgent data, the GisAgent must implement a setDbfField() function where DbfField is the name of field in the .dbf file associated with the Shapefile Note: this version of the function will read data from the origDatasource, and use that data in combination with data from the GisAgent to write the newDatasource

Parameters:
gisAgents -
origDatasource -
newDatasource -

writeShpUsingShp

public void writeShpUsingShp(java.util.Collection gisAgents,
                             java.lang.String origDatasource,
                             java.lang.String newDatasource)
A helper function for the writeAgents function

Parameters:
gisAgents -
origDatasource -
newDatasource -

writeAgentsNoShp

public void writeAgentsNoShp(java.util.Collection gisAgents,
                             com.bbn.openmap.proj.Projection proj,
                             java.lang.String datasource)
Writes agents created from OpenMap to a Shapefile (.shp, .dbf and .shx). Must be GisAgents, and need to be of an OpenMap type that can be cast to either EsriPoint, EsriPoly, or EsriPolygon (in other words GisAgents with OMGraphic of type Location, OMArc, and OMCircle will not work with this function)

Parameters:
gisAgents -
proj - - use the OpenMapDisplay class to get the projection
datasource - - Shapefile to write to (should end in .shp)

writeDbfFromAgents

public java.util.ArrayList writeDbfFromAgents(java.util.Collection gisAgents,
                                              java.lang.String datasource)
helper function for writeAgentsNoShp writes the dbf file from a list of GisAgents

Parameters:
gisAgents -
datasource -
Returns:

getShpType

public int getShpType(java.lang.String datasource)

buildEsriGraphicList

public com.bbn.openmap.dataAccess.shape.EsriGraphicList buildEsriGraphicList(java.util.Collection gisAgents)
Takes a Collection of GisAgents, gets the OMGraphic from each, and attempts to build an EsriGraphicList from them. Requires that the GisAgents OMGraphics can be casted to EsriGraphic

Parameters:
gisAgents -
Returns:
EsriGraphicList

buildEsriGraphicList

public com.bbn.openmap.dataAccess.shape.EsriGraphicList buildEsriGraphicList(java.util.Collection gisAgents,
                                                                             int shpType)
Takes a Collection of GisAgents, gets the OMGraphic from each, and attempts to build an EsriGraphicList from them. Uses the shpType to set the type of EsriGraphic used for the list Requires that the GisAgents OMGraphics can be casted to EsriGraphic

Parameters:
gisAgents -
shpType -
Returns:

buildFeatureArrayList

public anl.repast.gis.data.FeatureArrayList buildFeatureArrayList(java.util.Collection gisAgents,
                                                                  java.lang.String datasource)
helper function for writeAgents takes a Collection of GisAgents and a datasource and creates a FeatureArrayList to store the features

Parameters:
gisAgents -
datasource -
Returns:

writeFeatureArrayListToDbf

public void writeFeatureArrayListToDbf(java.util.Collection gisAgents,
                                       anl.repast.gis.data.FeatureArrayList featureList,
                                       java.lang.String origDatasource,
                                       java.lang.String newDatasource)
helper function for writeAgents takes the FeatueArrayList and writes it to a dbf file

Parameters:
gisAgents -
featureList -
origDatasource -
newDatasource -

getAttributeValues

public java.util.HashSet getAttributeValues(java.lang.String attributeName,
                                            java.lang.String dataSource)
for a given attribute in a datasource (.shp file) gets a set of all the attribute's values

Parameters:
attributeName -
dataSource -
Returns:

getEsriLayer

public com.bbn.openmap.plugin.esri.EsriLayer getEsriLayer(java.lang.String datasource)
given a shapefile, returns an OpenMap EsriLayer

Parameters:
datasource -
Returns:

getExtents

public float[] getExtents(java.lang.String datasource)
gets the extents for a shapefile The lat/lon extent of the EsriGraphicList contents, returned as miny, minx, maxy maxx in order of the array.

Parameters:
datasource -
Returns:

getExtents

public float[] getExtents(com.bbn.openmap.dataAccess.shape.EsriGraphicList egList)
gets the extents for an EsriGraphicList The lat/lon extent of the EsriGraphicList contents, returned as miny, minx, maxy maxx in order of the array.

Parameters:
egList -
Returns:

getExtents

public float[] getExtents(com.bbn.openmap.omGraphics.OMGraphic omg)
gets the extents for an OMGraphic The lat/lon extent of the EsriGraphic contents, returned as miny, minx, maxy maxx in order of the array.

Parameters:
omg -
Returns:

getCenter

public com.bbn.openmap.LatLonPoint getCenter(com.bbn.openmap.dataAccess.shape.EsriGraphic eg)
gets the center of the extents of the EsriGraphic

Returns:

getCenter

public com.bbn.openmap.LatLonPoint getCenter(com.bbn.openmap.dataAccess.shape.EsriGraphicList egList)
gets the center of the extents of the EsriGraphicList

Returns:

getCenter

public com.bbn.openmap.LatLonPoint getCenter(anl.repast.gis.OpenMapAgent omd)
gets the center of the extents of the OMGraphic Requires that the OMGraphic is an instance of EsriGraphic

Parameters:
omd -
Returns:

getCenter

public com.bbn.openmap.LatLonPoint getCenter(float[] extents)
gets the center of the extents

Returns:

getCenter

public com.bbn.openmap.LatLonPoint getCenter(java.lang.String datasource)
gets the center of the extents of the datasource Requires that the datasource is a Shapefile

Returns:

getArea

public double getArea(com.bbn.openmap.omGraphics.OMGraphic omGraphic)
Gets the area for an OMGraphic using the com.bbn.openmap.geo.Geo class

Parameters:
omGraphic -
Returns:

getArea

public double getArea(com.bbn.openmap.dataAccess.shape.EsriGraphic esriGraphic)
Gets the area for an EsriGraphic using the com.bbn.openmap.geo.Geo class

Returns:

getSetMethodForAttributeType

public java.lang.reflect.Method getSetMethodForAttributeType(java.lang.Class clazz,
                                                             org.geotools.feature.AttributeType at)
helper function given an Attribute type (generally from a Shapefile's dbf file) get the related set method

Parameters:
clazz -
at -
Returns:

getSetMethodForName

public java.lang.reflect.Method getSetMethodForName(java.lang.Class clazz,
                                                    java.lang.String columnName)
helper function given an Column name (generally from a Shapefile's dbf file) get the related set method

Parameters:
clazz -
Returns:

getGetMethodForName

public java.lang.reflect.Method getGetMethodForName(java.lang.Class clazz,
                                                    java.lang.String name)
helper function given an Column name (generally from a Shapefile's dbf file) get the related get method

Parameters:
clazz -
Returns:

getGetMethodForAttributeType

public java.lang.reflect.Method getGetMethodForAttributeType(java.lang.Class clazz,
                                                             org.geotools.feature.AttributeType at)
helper function given an Attribute type (generally from a Shapefile's dbf file) get the related get method

Parameters:
clazz -
at -
Returns:

getAttributePosition

public int getAttributePosition(java.lang.String name,
                                org.geotools.feature.FeatureType ft)
given the feature type and the name, get the Attribute Position

Parameters:
name -
ft -
Returns: