Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
bkickhoefer
bkickhoefer's Profile
1
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
The contains() method is only implemented for paths.
[2 Replies]
10-Dec-2012 05:08 PM
Forum:
Programming Questions
Hi all,
I figured out a way of how to read in an ESRI shape file, and how to convert the features into a PShape:
private PShape getPShape(Feature ft) {
PShape featureShape;
GeometryCollection gc = (GeometryCollection) ft.getDefaultGeometry();
PVector[] scrCoords = getScreenCoords(gc);
if(gc instanceof MultiLineString){
featureShape = createShape(LINES);
for(PVector scrCoord : scrCoords){
featureShape.vertex(scrCoord.x, scrCoord.y);
}
featureShape.noFill();
featureShape.stroke(150, 50, 50);
featureShape.strokeWeight(1);
featureShape.end();
} else if(gc instanceof MultiPolygon){
featureShape = createShape();
for(PVector scrCoord : scrCoords){
featureShape.vertex(scrCoord.x, scrCoord.y);
}
featureShape.noFill();
featureShape.stroke(255, 255, 255);
featureShape.strokeWeight(5);
featureShape.end(CLOSE);
} else {
throw new RuntimeException("Unsupported GeometryType: " + gc.getGeometryType());
}
private PVector[] getScreenCoords(GeometryCollection gc) {
Coordinate[] coords = gc.getCoordinates();
PVector[] scrCoords = new PVector[coords.length];
for(int i=0; i<coords.length; i++){
PVector coord = new PVector((float) coords[i].x, (float) coords[i].y);
PVector scrCoord = geoToScreen(coord);
scrCoords[i] = scrCoord;
}
return scrCoords;
}
Now I would like to fill the PShape whenever the mouse is over it. The obvious way (see below) gives me the error message of the topic header.
@Override
public void draw(){
shape(munich);
for(PShape childShape : munich.getChildren()){
if(childShape.contains(mouseX, mouseY)){
childShape.fill(255, 255, 255);
}
}
}
I found some external libraries (e.g.
http://www.ricardmarxer.com/geomerative/
or
http://code.google.com/p/gicentre-geomap/)
that might help here, but their classes limit my work in other ways. So I would be interested if someone has an idea about how to solve my problem with "standard processing".
Any comments are very welcome!
Thanks in advance,
Benjamin
«Prev
Next »
Moderate user : bkickhoefer
Forum