public class GeoMap extends java.lang.Object implements Geographic
Modifier and Type | Field and Description |
---|---|
static float |
NO_DATA
Value used to indicate no data.
|
Constructor and Description |
---|
GeoMap(float xOrigin,
float yOrigin,
float mapWidth,
float mapHeight,
processing.core.PApplet parent)
Creates a map with the given bounds.
|
GeoMap(processing.core.PApplet parent)
Creates a map with the default bounds.
|
Modifier and Type | Method and Description |
---|---|
void |
draw()
Draws the map in the parent sketch.
|
void |
draw(int id)
Draws the feature that matches the given id.
|
void |
draw(java.lang.String regex,
int col)
Draws all features that match the given attribute stored in the given column of
the attribute table.
|
processing.core.PVector |
geoToScreen(float geoX,
float geoY)
Should provide the screen coordinates corresponding to the given geographic coordinates.
|
AttributeTable |
getAttributes()
Deprecated.
Use getAttributeTable instead that uses Processing's own Table class to store attributes.
|
processing.data.Table |
getAttributeTable()
Reports the attribute table associated with this geoMap object.
|
java.util.Map<java.lang.Integer,Feature> |
getFeatures()
Reports the collection of features that make up this geoMap object.
|
int |
getID(float screenX,
float screenY)
Reports the ID of the feature at the given location in screen coordinates or -1
if no feature found.
|
float |
getMaxGeoX()
Reports the maximum geographic coordinate in the x-direction.
|
float |
getMaxGeoY()
Reports the maximum geographic coordinate in the y-direction.
|
float |
getMinGeoX()
Reports the minimum geographic coordinate in the x-direction.
|
float |
getMinGeoY()
Reports the minimum geographic coordinate in the y-direction.
|
int |
getNumLines()
Reports the number of line objects that are stored in this geoMap object.
|
int |
getNumLineVertices()
Reports the total number of vertices in all line features stored in this geoMap object.
|
int |
getNumPoints()
Reports the number of point objects that are stored in this geoMap object.
|
int |
getNumPolygonParts()
Reports the total number of polygon parts in all polygon features stored in this geoMap object.
|
int |
getNumPolygonVertices()
Reports the total number of vertices in all polygon features stored in this geoMap object.
|
int |
getNumPolys()
Reports the number of polygon objects that are stored in this geoMap object.
|
void |
readFile(java.lang.String fileName)
Reads geometry and attributes from a shapefile.
|
processing.core.PVector |
screenToGeo(float screenX,
float screenY)
Should provide the geographic coordinates corresponding to the given screen coordinates.
|
void |
setAttributes(AttributeTable attributes)
Deprecated.
Use setAttributeTable() instead that uses Processing's own Table class.
|
void |
setAttributeTable(processing.data.Table attributes)
Sets the attribute table to be associated with this geoMap object.
|
void |
setFeatures(java.util.Map<java.lang.Integer,Feature> features)
Sets the collection of features that make up this geoMap object.
|
void |
writeAttributesAsTable(int maxNumRows)
Writes the attributes of this geoMap as formatted text to standard output.
|
void |
writeAttributesAsTable(java.io.PrintWriter writer,
int maxNumRows)
Writes the attributes of this geoMap as formatted text to the given writer.
|
void |
writeAttributesAsTable(java.lang.String fileName,
int maxNumRows)
Writes the attributes of this geoMap as formatted text to the file with the given name.
|
void |
writeFile(java.lang.String fileName)
Writes geometry and attributes of this geoMap object as a shapefile.
|
public static final float NO_DATA
public GeoMap(processing.core.PApplet parent)
parent
- The parent sketch.public GeoMap(float xOrigin, float yOrigin, float mapWidth, float mapHeight, processing.core.PApplet parent)
xOrigin
- The position of the map from the left of the sketch.yOrigin
- The position of the map from the top of the sketch.mapWidth
- The width of the map.mapHeight
- The height of the map.parent
- The parent sketch.public void draw()
public void draw(int id)
id
- ID of feature to draw.public void draw(java.lang.String regex, int col)
regex
- Regular expression to match the ID of attribute identifying features to draw.col
- Column in the attribute table (where ID is column 0) to search.public int getID(float screenX, float screenY)
screenX
- x-coordinate of screen location to query.screenY
- y-coordinate of screen location to query.public processing.core.PVector geoToScreen(float geoX, float geoY)
geoToScreen
in interface Geographic
geoX
- Geographic x coordinate.geoY
- Geographic y coordinate.public processing.core.PVector screenToGeo(float screenX, float screenY)
screenToGeo
in interface Geographic
screenX
- Screen x coordinate.screenY
- Screen y coordinate.public void readFile(java.lang.String fileName)
fileName
- The name of the file without extension. A shapefile consists of three separate files
called fileName.shp (the geometry), fileName.dbf (the attributes) and fileName.dbx
(an index file).public void writeFile(java.lang.String fileName)
fileName
- The name of the file without extension. A shapefile consists of three separate files
called fileName.shp (the geometry), fileName.dbf (the attributes) and fileName.dbx
(an index file).public int getNumPoints()
public int getNumLines()
public int getNumPolys()
public int getNumLineVertices()
public int getNumPolygonVertices()
public int getNumPolygonParts()
public java.util.Map<java.lang.Integer,Feature> getFeatures()
public void setFeatures(java.util.Map<java.lang.Integer,Feature> features)
features
- New features to be stored in the geoMap.public processing.data.Table getAttributeTable()
@Deprecated public AttributeTable getAttributes()
@Deprecated public void setAttributes(AttributeTable attributes)
attributes
- New attribute table to be associated with this geoMap.public void setAttributeTable(processing.data.Table attributes)
attributes
- New attribute table to be associated with this geoMap.public float getMinGeoX()
public float getMinGeoY()
public float getMaxGeoX()
public float getMaxGeoY()
public void writeAttributesAsTable(int maxNumRows)
maxNumRows
- Maximum number of rows of the table to display.public void writeAttributesAsTable(java.lang.String fileName, int maxNumRows)
fileName
- Name of file to contain the formatted output.maxNumRows
- Maximum number of rows of the table to display.public void writeAttributesAsTable(java.io.PrintWriter writer, int maxNumRows)
writer
- Output writer in which to send attribute table contents.maxNumRows
- Maximum number of rows of the attribute table to display.