|
From: Miles <mil...@sy...> - 2005-10-11 20:48:52
|
Hi,
I am working at an application that requires to clip features read from
a shape file. When I looked at the Clipper, it requires an instance of
CoordinateSystem. Can this coordinatesystem object be null? Attached are
my codes. The commented part are what I want to do with the read feature
from the file.
Thanks a bunch,
Miles
Vector result = new Vector();
URL shapeURL = f.toURL();
ShapefileDataStore store = new ShapefileDataStore(shapeURL);
String name = store.getTypeNames()[0];
FeatureSource source = store.getFeatureSource(name);
System.out.println("coordinate system: " +
source.getSchema().getDefaultGeometry().getCoordinateSystem()); //
this always seem to return null
// rectangle2D = new Rectangle(envelop.get);
// clipper = new Clipper(rectangle2D, null);
FeatureResults fsShape = source.getFeatures();
FeatureReader reader = fsShape.reader();
Feature feature ;
while (reader.hasNext()) {
feature = reader.next();
// apply clip to the feature's geometry. create an application specifc
object using the feature atrributes and the clipped geometry.
Object o = createObject(feature);
result.add(o);
}
reader.close();
return result;
|