|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.reades.mapthing.Generic
public class Generic
This serves as a Generic template and super-class for implementations of various entity-drawing classes.
You wouldn't call this directly, but it is used by the sub-classes to do things like open shape files (and save a reference to the FeatureCollection object, and to map the geographic coordinates on to the plane of the Processing sketch window).
Package designed to hold objects used to translate between Shape and CSV files, and Processing's PShape, PImage and other sketch drawing classes.
I am deeply indebted for the CSV code to the GeoTools example available here: http://docs.geotools.org/stable/userguide/examples/csv2shp.html
I should also definitely acknowledge the input of Camilo Vargas, without which this would never have happened!
Field Summary | |
---|---|
boolean |
DEBUG
|
Constructor Summary | |
---|---|
Generic(BoundingBox b,
A default implementation. |
|
Generic(BoundingBox b,
SimpleFeature f)
A default implementation. |
Method Summary | |
---|---|
void |
appendNearestFeatures(Generic gs,
double maxDistance)
Incomplete implementation -- this is supposed to allow you to select features falling within a particular distance of a polygon, but as yet I've not quite figured how to do it properly. |
ReferencedEnvelope |
getBounds()
Get the boundary envelope of the shape file itself |
|
getCentroids()
Returns the centroids of an object in a Processing sketch. |
|
getFeatures()
Retrieves all features contained in the data source and returns them as a FeatureCollection. |
|
getMultipleFeaturesById(String field,
Set<String> ids)
Deprecated. |
|
getMultipleFeaturesById(String field,
String id)
Deprecated. |
|
getMultipleFeaturesById(String field,
String[] ids)
Deprecated. |
|
getMultipleFeaturesByPattern(String field,
Set<String> ids)
Retrieves all features identified by a particular id in a given field of the shape file and then returns them as a FeatureCollection. |
|
getMultipleFeaturesByPattern(String field,
String id)
Retrieves the set of features identified by a particular 'id' in a given field of a shape file and then returns it as a FeatureCollection. |
|
getMultipleFeaturesByPattern(String field,
String[] ids)
Retrieves all features identified by a particular id in a given field of the shape file and then returns them as a FeatureCollection. |
|
getMultipleFeaturesByValue(String field,
double min)
Select a set of attributes using a double-precision value instead of a SQL-like string. |
int |
getProjection()
|
int |
getProjection(
|
int |
interpolateColor(PApplet a,
float value,
float min,
float max)
|
float |
map(float x1,
float xMin,
float xMax,
float xRemapMin,
float xRemapMax)
Used by all classes to map their contents on to the plane of the sketch. |
void |
setColorScale(int lowColor,
int highColor,
int numberOfSteps)
Apply a scale that will be used for values or categories within this object. |
void |
setColorScale(int lowColor,
int midColor,
int highColor,
int numberOfSteps)
Apply a scale that will be used for values or categories within this object. |
void |
setColourScale(int lowColour,
int highColour,
int numberOfSteps)
Apply a scale that will be used for values or categories within this object. |
void |
setColourScale(int lowColour,
int midColour,
int highColour,
int numberOfSteps)
Apply a scale that will be used for values or categories within this object. |
void |
setGlobalSimplificationThreshold(double d)
Used by the Lines and Polygons objects to implement various types of simplification appropriate to the object being displayed. |
void |
setLabelField(int fieldId)
Specify the column position that contains the values that you want to use as a label in your Processing sketch. |
void |
setLabelField(String fieldName)
Specify the name of the column that contains the values (i.e. |
void |
setLocalSimplificationThreshold(double d)
Used by the Lines and Polygons objects to implement various types of simplification appropriate to the object being displayed. |
void |
setValueField(int fieldId)
Specify the column position that contains the values that you want to use in your Processing sketch. |
void |
setValueField(String fieldName)
Specify the name of the column that contains the values (i.e. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public boolean DEBUG
Constructor Detail |
---|
public Generic(BoundingBox b,f)
A default implementation. Often used to instantiate polygons and lines from within the shape file as separate, draw-able entities within the sketch.
b
- the BoundingBox object defining the default viewf
- the FeatureCollection used to instantiate the objectpublic Generic(BoundingBox b, SimpleFeature f)
A default implementation. Often used to instantiate polygons and lines from within the shape file as separate, draw-able entities within the sketch. Note that we create a FeatureCollection even though there's only one feature contained within it. This is to ensure consistency in handling objects across the pipeline.
b
- the BoundingBox object defining the default viewf
- the SimpleFeature retrieved from the shape fileMethod Detail |
---|
public void setLocalSimplificationThreshold(double d)
Used by the Lines and Polygons objects to implement various types of simplification appropriate to the object being displayed. This works in the units of the shape file itself, so in the case of OSGB-mapped shapes it would be metres.
Note that we have two types of simplifcation here: this one works on each object individually, while the other method works on them all simultaneously.
d
- the distance over which to simplifysetGlobalSimplificationThreshold
public void setGlobalSimplificationThreshold(double d)
Used by the Lines and Polygons objects to implement various types of simplification appropriate to the object being displayed. This works in the units of the shape file itself, so in the case of OSGB-mapped shapes it would be metres.
Note that we have two types of simplifcation here: this one works on them all at once, while the other method works on each one individually.
d
- the distance over which to simplifysetLocalSimplificationThreshold
publicgetCentroids()
public float map(float x1, float xMin, float xMax, float xRemapMin, float xRemapMax)
Used by all classes to map their contents on to the plane of the sketch. So we translate between the range of the shape file and range of the viewport we want to work with. Note that this can produce remapped values that are negative, below xRemapMin, or exceed xRemapMax.
x1
- the input position along the x- or y-axisxMin
- the expected minimum value of the range from which x1 is drawnxMax
- the expected maximum value of the range from which x1 is drawnxRemapMin
- what we are mapping xMin on toxRemapMax
- what we are mapping xMax on to
publicgetMultipleFeaturesByPattern(String field, String id)
Retrieves the set of features identified by a particular 'id' in a given field of a shape file and then returns it as a FeatureCollection. Note that it makes no assumptions about the type of feature returned, you must take care of this yourself.
The main thing that this offers is the ability to retrieve results based on a 'LIKE' query. So if you pass in '%Greater%' as the 'id', and CITY_NAME as the field, then you might get back 'Greater London', 'Greater Manchester', etc.
publicgetMultipleFeaturesById(String field, String id)
field
- id
-
publicgetMultipleFeaturesByPattern(String field, String[] ids)
Retrieves all features identified by a particular id in a given field of the shape file and then returns them as a FeatureCollection. Note that it makes no assumptions about the type of feature returned, you must take care of this yourself.
The principal difference between this and the version
that takes a Set
publicgetMultipleFeaturesById(String field, String[] ids)
field
- ids
-
publicgetMultipleFeaturesByPattern(String field, Set<String> ids)
Retrieves all features identified by a particular id in a given field of the shape file and then returns them as a FeatureCollection. Note that it makes no assumptions about the type of feature returned, you must take care of this yourself.
The principal difference between this and the version that takes a String[] is that the return values will not necessarily be ordered in any particular way. So if the order of the rows in the Shape file are meaningful in some way then you should use the other method instead.
publicgetMultipleFeaturesById(String field, Set<String> ids)
field
- ids
-
publicgetMultipleFeaturesByValue(String field, double min)
field
- the name of the column in which the values can be foundmin
- the minimum value which must be exceeded for the feature to be selected
publicgetFeatures()
public ReferencedEnvelope getBounds()
public void setLabelField(String fieldName)
fieldName
- public void setLabelField(int fieldId)
fieldId
- public void setValueField(String fieldName)
fieldName
- public void setValueField(int fieldId)
fieldId
- public void setColorScale(int lowColor, int highColor, int numberOfSteps)
lowColor
- highColor
- numberOfSteps
- public void setColourScale(int lowColour, int highColour, int numberOfSteps)
lowColour
- highColour
- numberOfSteps
- public void setColorScale(int lowColor, int midColor, int highColor, int numberOfSteps)
lowColor
- midColor
- highColor
- numberOfSteps
- public void setColourScale(int lowColour, int midColour, int highColour, int numberOfSteps)
lowColour
- a Processing color object representing the low-value colourmidColour
- a Processing color object representing the mid-value colourhighColour
- a Processing color object representing the high-value colournumberOfSteps
- public int interpolateColor(PApplet a, float value, float min, float max)
public int getProjection()
public int getProjection(f)
public void appendNearestFeatures(Generic gs, double maxDistance)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |