Hi Everyone,
I am seeing an odd exception that I am having trouble figuring out and
wondering if any of you have run into this. Basically, I have points
(lat/long) that are entered and then I attempt to create a LineString
sending in these points as Coordinates. It seems that the LineString gets
created fine but when adding the FeatureLayer to the map I get the following
exception (seems the Envelope is null?):
Dec 09, 2015 4:57:29 PM org.geotools.map.MapContent getMaxBounds
WARNING: Unable to determine bounds of org.geotools.map.FeatureLayer[,
VISIBLE]
java.lang.NullPointerException
at
com.vividsolutions.jts.geom.Envelope.expandToInclude(Envelope.java:396)
at
com.vividsolutions.jts.geom.impl.CoordinateArraySequence.expandEnvelope(Coor
dinateArraySequence.java:255)
at
com.vividsolutions.jts.geom.LineString.computeEnvelopeInternal(LineString.ja
va:232)
at
com.vividsolutions.jts.geom.Geometry.getEnvelopeInternal(Geometry.java:656)
at
org.geotools.data.collection.CollectionDataStore.getBoundsInternal(Collectio
nDataStore.java:152)
at
org.geotools.data.collection.CollectionDataStore.getBounds(CollectionDataSto
re.java:133)
at
org.geotools.data.AbstractFeatureSource.getBounds(AbstractFeatureSource.java
:318)
at
org.geotools.data.AbstractFeatureSource.getBounds(AbstractFeatureSource.java
:286)
at org.geotools.map.FeatureLayer.getBounds(FeatureLayer.java:195)
at org.geotools.map.MapContent.getMaxBounds(MapContent.java:600)
at
org.geotools.swing.AbstractMapPane.setFullExtent(AbstractMapPane.java:939)
at
org.geotools.swing.AbstractMapPane.layerAdded(AbstractMapPane.java:794)
at org.geotools.map.MapContent.fireLayerAdded(MapContent.java:467)
at org.geotools.map.MapContent$LayerList.add(MapContent.java:960)
at org.geotools.map.MapContent$LayerList.add(MapContent.java:941)
at
com.jjmtechcorp.fishingtracker.FishingTrackerApp.addPointToLine(FishingTrack
erApp.java:663)
Here is the code snippets for creating the LineString and adding the layer:
Coordinate[] positions = new Coordinate[2];
// Basically contains the 2 coordinates; Ex: coord.x = longitude; coord.y =
latitude
SimpleFeatureTypeBuilder typeBldr = new
SimpleFeatureTypeBuilder();
typeBldr.setName("LineBldr");
typeBldr.add("line", LineString.class,
mapPane.getMapContent().getCoordinateReferenceSystem());
typeBldr.add("id", Integer.class);
final SimpleFeatureType lineString =
typeBldr.buildFeatureType();
final SimpleFeatureBuilder BLDR = new
SimpleFeatureBuilder(lineString);
lineCollection = new DefaultFeatureCollection();
lineCollectionList.add(lineCollection);
LineString lineString =
geometryFactory.createLineString(positions);
BLDR.add(lineString);
BLDR.add(getLineId());
SimpleFeature lineFeature = bldr.buildFeature(null);
lineCollection.add(lineFeature);
Style lineStyle = SLD.createLineStyle(menuData.getColor(),
1.0f);
Layer lineLayer = new FeatureLayer(lineCollection, lineStyle);
map.layers().add(layerIndex, lineLayer);
Any help you can provide would be much appreciated.
Thanks,
David
---------------------------------------------------
David Purdy
Owner/President
JJM Technologies Corporation
Email: [email protected]
Phone: 508.972.1266
------------------------------------------------------------------------------
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users