So that visitor is supposed to go through the query and figure out a
bounding box ..
All the test cases for ExtractBoundsFilterVisitorTest pass, and there are
several that reference a propertyName.
Stepping through the code it is not obvious but it appears to work.
propertyName does indeed produce a null.
All the geometry filters that can are of the form:
public Object visit( Crosses filter, Object data ) {
data = filter.getExpression1().accept(this, data);
data = filter.getExpression2().accept(this, data);
return data;
}
So while I do not enjoy this visitor it is managing to return a bounding
box ... focus on the following two cases:
* PropertyName - which returns null
* Literal - which will do its best to return a Geometry
public Object visit( Literal expression, Object data ) {
ReferencedEnvelope bbox = bbox( data );
Object value = expression.getValue();
if (value instanceof Geometry) {
Geometry geometry = (Geometry) value;
Envelope bounds = geometry.getEnvelopeInternal();
if(bbox != null) {
bbox.expandToInclude(bounds);
return bbox;
} else {
return bbox(bounds);
}
} else {
LOGGER.finer("LiteralExpression ignored!");
}
return bbox;
}
--
Jody Garnett
On 27 February 2014 at 09:32, Hal Mirsky <hmir...@aseg.com> wrote:
> Hello,
>
> While running the SelectionLab example with 11-RC1, I get a null pointer
> exception when I use the ‘select tool’ to click on a feature.
> Specifically, the exception is raised on the call to
> selectedFeatures.features(); I’ve traced it to the
> ExtractBoundsFilterVisitor.visit function returning null. Does this look
> like a bug?
>
>
>
> // from SelectionLab.java:
>
>
>
> AffineTransform screenToWorld = mapFrame
> .getMapPane().getScreenToWorldTransform();
>
> Rectangle2D worldRect =
> screenToWorld.createTransformedShape(screenRect).getBounds2D();
>
> ReferencedEnvelope bbox = *new* ReferencedEnvelope(
>
> worldRect,
>
> mapFrame
> .getMapPane().getMapContent().getCoordinateReferenceSystem());
>
>
>
> /*
>
> * Create a Filter to select features that intersect with
>
> * the bounding box
>
> */
>
> Filter filter = ff.intersects(ff.property(geometryAttributeName), ff
> .literal(bbox));
>
>
>
> /*
>
> * Use the filter to identify the selected features
>
> */
>
> *try* {
>
> SimpleFeatureCollection selectedFeatures =
>
> featureSource.getFeatures(filter);
>
>
>
> SimpleFeatureIterator iter = selectedFeatures.features();
>
>
>
>
>
>
>
> // from ExtractBoundsFilterVisitor
>
> @Override
>
> *public* Object visit(PropertyName expression, Object data) {
>
> *return* *null*;
>
> }
>
>
>
> Here’s the stack trace:
>
>
>
> Mouse click at: DirectPosition2D[6349881.5871864, 2029348.2224553742]
>
> *java.lang.NullPointerException*
>
> at
> org.geotools.data.shapefile.ShapefileFeatureSource.getReaderInternal(
> *ShapefileFeatureSource.java:237*)
>
> at
> org.geotools.data.shapefile.ShapefileFeatureStore.getReaderInternal(
> *ShapefileFeatureStore.java:126*)
>
> at org.geotools.data.store.ContentFeatureSource.getReader(
> *ContentFeatureSource.java:563*)
>
> at org.geotools.data.store.ContentFeatureCollection.features(
> *ContentFeatureCollection.java:165*)
>
> at com.aseg.StyleLab.SelectionLab.selectFeatures(
> *SelectionLab.java:217*)
>
> at com.aseg.StyleLab.SelectionLab$1$1.onMouseClicked(
> *SelectionLab.java:161*)
>
> at
> org.geotools.swing.event.DefaultMapMouseEventDispatcher.mouseClicked(
> *DefaultMapMouseEventDispatcher.java:99*)
>
> at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
>
> at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
>
> at java.awt.AWTEventMulticaster.mouseClicked(Unknown Source)
>
> at java.awt.Component.processMouseEvent(Unknown Source)
>
> …
>
>
>
> Thanks for any feedback,
>
> Hal
>
>
> ------------------------------------------------------------------------------
> Flow-based real-time traffic analytics software. Cisco certified tool.
> Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer
> Customize your own dashboards, set traffic alerts and generate reports.
> Network behavioral analysis & security monitoring. All-in-one tool.
>
> http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk
> _______________________________________________
> GeoTools-GT2-Users mailing list
> GeoTools-GT2-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
>
------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users