com.reades.mapthing
Class Points

java.lang.Object
  extended by com.reades.mapthing.Generic
      extended by com.reades.mapthing.Points
All Implemented Interfaces:
Serializable

public class Points
extends Generic
implements Serializable

Creates points from a Point shape file in ArcGIS.

See Also:
Serialized Form

Field Summary
 boolean DEBUG
           
 
Constructor Summary
Points(BoundingBox b,  f)
          Instantiate the Points object with a BoundingBox and Feature Collection object.
Points(BoundingBox b, String r)
          Instantiate the GeoLine object with a BoundingBox and String.
 
Method Summary
 void dedupe(boolean useFirst)
          Use to remove duplicates -- by geographical coordinates -- from the data you are about to show.
 ArrayList<Coordinate> getCoordinates()
          Returns the raw coordinates without any transformation to fit into the sketch.
 ArrayList<Node> getCoordinates(PApplet a)
          Return an ArrayList, each row of which contains a single Node object.
 void label(PApplet a)
           
 void labelOffset(int x, int y)
           
 void project(PApplet a, float w, float h)
          Draws all of the points contained in a Points object loaded from a file.
 void project(PApplet a, PGraphics p, float w, float h)
          Draws all of the points contained in a Points object loaded from a file.
 void project(PApplet a, PGraphics p, PImage i, float w, float h)
          Draws all of the points contained in a Points object loaded from a file.
 void project(PApplet a, PImage i, float w, float h)
          Draws all of the points contained in a Points object loaded from a shape file.
 void projectAreas(PApplet a, float r, float max)
          Scales the size of the point according to the value of the data associated with the point.
 void projectAreasAndValues(PApplet a, float r, float min, float max)
          Scales the size of the point and the colour according to the data value associated with that location.
 void projectValues(PApplet a, float w, float h, float min, float max)
          Colours all of the points according to the specified colour scale.
 void transformCoordinates(PApplet a)
          Must be called before you can display the points in a Processing sketch.
 
Methods inherited from class com.reades.mapthing.Generic
appendNearestFeatures, getBounds, getCentroids, getFeatures, getMultipleFeaturesById, getMultipleFeaturesById, getMultipleFeaturesById, getMultipleFeaturesByPattern, getMultipleFeaturesByPattern, getMultipleFeaturesByPattern, getMultipleFeaturesByValue, getProjection, getProjection, interpolateColor, map, setColorScale, setColorScale, setColourScale, setColourScale, setGlobalSimplificationThreshold, setLabelField, setLabelField, setLocalSimplificationThreshold, setValueField, setValueField
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public boolean DEBUG
Constructor Detail

Points

public Points(BoundingBox b,
              String r)
Instantiate the GeoLine object with a BoundingBox and String. Depending on whether the String ends in .csv or .shp we will employ the appropriate tool to open and read the data.

Parameters:
b - the bounding box of the default view
r - a String that allows us to determine the type of resource to open

Points

public Points(BoundingBox b,
               f)
Instantiate the Points object with a BoundingBox and Feature Collection object.

Parameters:
b - the bounding box of the default viewport
f - a reference to FeatureCollection of SimpleFeature objects
Method Detail

dedupe

public void dedupe(boolean useFirst)
Use to remove duplicates -- by geographical coordinates -- from the data you are about to show. You should specify a de-duping field and a boolean to indicate whether you want the first or last value encountered. This can be very helpful when you have a lot of points in your shape file and want to simplify the projection (or remove potential sources of confusion in the mapping process).

Parameters:
useFirst - use the first point encountered in the index when de-duping points.

transformCoordinates

public void transformCoordinates(PApplet a)
Must be called before you can display the points in a Processing sketch. You don't normally need to call this directly since it will be called automatically when you call points.project(this). However, this does allow you to manually perform operations if you are trying to be very clever, and basically all we're doing is using the height and width of the sketch so that we can remap the coordinates of the shape file into the plain of the sketch itself.

Parameters:
a - a Processing PApplet object

getCoordinates

public ArrayList<Node> getCoordinates(PApplet a)
Return an ArrayList, each row of which contains a single Node object. The idea is that each entry represents a separate point that can be drawn in the sketch. The simplest case is to then just pass the entire ArrayList straight to the drawGeoPoint() method in GeoPApplet.

Returns:
An ArrayList of Nodes

getCoordinates

public ArrayList<Coordinate> getCoordinates()
Returns the raw coordinates without any transformation to fit into the sketch. In this case you can manipulate the underlying SimpleFeatures to perform other operations.

Returns:
ArrayList

project

public void project(PApplet a,
                    float w,
                    float h)
Draws all of the points contained in a Points object loaded from a file. The simplest way to work with this method is to set the color, fill, and stroke in your sketch and then just call this function by passing it the Applet instance (probably by saying: object.project(this, width, height).

Parameters:
a - a Processing PApplet object
w - a float indicating the width of the ellipse to draw
h - a float indicating the height of the ellipse to draw

projectValues

public void projectValues(PApplet a,
                          float w,
                          float h,
                          float min,
                          float max)

Colours all of the points according to the specified colour scale. The default values are set as white to black, so you'll probably want to override these. If a value falls below the minimum then it will be assigned the colour of the minimum value. If a value exceeds the maximum then it will be assigned the colour of the maximum value.

In the longer run I'll try to implement a version that doesn't require you to specify these values.

Parameters:
a - the PApplet (usually just referred to in a sketch as 'this')
w - the width of the ellipse you want to draw on top of the point
h - the height of the ellipse you want to draw on top of the point
min - the minimum value to use (against which to scale the point values)
max - the maximum value to use (against which to scale the point values)

projectAreas

public void projectAreas(PApplet a,
                         float r,
                         float max)

Scales the size of the point according to the value of the data associated with the point. You pass in a radius value that indicates the desired area to associate with the maximum value specified by the max parameter. In this case, values that exceed the maximum will continue to scale up to give points whose radius exceeds the specified r value.

In the long run I'll try to implement a version that doesn't require you to specify a maximum.

Parameters:
a - the PApplet (usually just referred to in a sketch as 'this')
r - the desired maximum radius
max - the expected maximum value

projectAreasAndValues

public void projectAreasAndValues(PApplet a,
                                  float r,
                                  float min,
                                  float max)

Scales the size of the point and the colour according to the data value associated with that location.

In the long run I'll try to implement a version that doesn't require you to specify a minimum or maximum.

Parameters:
a - the PApplet (usually just referred to in a sketch as 'this')
r - the desired maximum radius
min - the minimum value to use (against which to scale the point values)
max - the maximum value to use (against which to scale the point values)
See Also:
projectAreas, projectValues

project

public void project(PApplet a,
                    PImage i,
                    float w,
                    float h)
Draws all of the points contained in a Points object loaded from a shape file. The simplest way to work with this method is to set the color, fill, and stroke in your sketch and then just call this function by passing it the Applet instance (probably by saying: object.project(this, image, width, height). Note that if you want the image to appear right on top of the coordinates then you will need to call "imageMode(CENTER)" in your sketch first.

Parameters:
a - a Processing PApplet object
i - a PImage object containing the image we want to draw at each point
w - a float indicating the width of the image to draw
h - a float indicating the height of the image to draw

project

public void project(PApplet a,
                    PGraphics p,
                    float w,
                    float h)

Draws all of the points contained in a Points object loaded from a file. This one differs from the version without a PGraphics object in that it allows you to use the graphics object as a buffer and won't write directly to the Applet view.

The simplest way to work with this method is to set the color, fill, and stroke in your sketch and then just call this function by passing it the Applet and Graphics instances.

Parameters:
a - a Processing PApplet object
p - a Processing PGraphics object
w - a float indicating the width of the ellipse to draw
h - a float indicating the height of the ellipse to draw

project

public void project(PApplet a,
                    PGraphics p,
                    PImage i,
                    float w,
                    float h)

Draws all of the points contained in a Points object loaded from a file. This one differs from the version without a PGraphics object in that it allows you to use the graphics object as a buffer and won't write directly to the Applet view.

The simplest way to work with this method is to set the color, fill, and stroke in your sketch and then just call this function by passing it the Applet and Graphics instances

Note that if you want the image to appear right on top of the coordinates then you will need to call "imageMode(CENTER)" in your sketch first.

Parameters:
a - a Processing PApplet object
p - a Processing PGraphics object
i - a PImage object containing the image we want to draw at each point
w - a float indicating the width of the image to draw
h - a float indicating the height of the image to draw

labelOffset

public void labelOffset(int x,
                        int y)

label

public void label(PApplet a)


Processing library MapThing by Jon Reades. (C) 2013