What happens if you use the addLayer method provided for this process instead of poking the internals directly?
map.addLayer(layer); Ian On 14 December 2015 at 14:18, David Purdy <david.pu...@jjmtechcorp.com> wrote: > Sure. Like I mentioned in the email, when I add the FeatureLayer to the > map: > > > > map.layers().add(layerIndex, lineLayer); > > > > And below is what the Coordinate array contains: > > > > entry 0 - coord.x = -71.0, coord.y=41.5 > > entry 1 - coord.x = -71.416666666, coord.y = 41.75 > > > > Appreciate your time. > > > > --------------------------------------------------- > > *David Purdy* > > *Owner/President* > > *JJM Technologies Corporation* > > *Email: david.pu...@jjmtechcorp.com <david.pu...@jjmtechcorp.com>* > > *Phone: 508.972.1266* > > > > *From:* Ian Turton [mailto:ijtur...@gmail.com] > *Sent:* Monday, December 14, 2015 9:08 AM > *To:* David Purdy > *Cc:* geotools-users > *Subject:* Re: [Geotools-gt2-users] NullPointerException adding layer for > a LineString to a map > > > > Could you at least point out which line is throwing the exception > - > com.jjmtechcorp.fishingtracker.FishingTrackerApp.addPointToLine(FishingTrackerApp.java:663) > is not actually any help. We'd also need to know what is in the corrdinate > array to even start guessing what might be happening > > > > Ian > > > > On 14 December 2015 at 13:22, David Purdy <david.pu...@jjmtechcorp.com> > wrote: > > Has anyone seen this type of problem? > > > > --------------------------------------------------- > > *David Purdy* > > *Owner/President* > > *JJM Technologies Corporation* > > *Email: david.pu...@jjmtechcorp.com <david.pu...@jjmtechcorp.com>* > > *Phone: 508.972.1266* > > > > *From:* David Purdy [mailto:david.pu...@jjmtechcorp.com] > *Sent:* Thursday, December 10, 2015 10:25 AM > *To:* geotools-gt2-users@lists.sourceforge.net > *Subject:* [Geotools-gt2-users] NullPointerException adding layer for a > LineString to a map > > > > 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(CoordinateArraySequence.java:255) > > > > at > com.vividsolutions.jts.geom.LineString.computeEnvelopeInternal(LineString.java:232) > > at > com.vividsolutions.jts.geom.Geometry.getEnvelopeInternal(Geometry.java:656) > > at > org.geotools.data.collection.CollectionDataStore.getBoundsInternal(CollectionDataStore.java:152) > > at > org.geotools.data.collection.CollectionDataStore.getBounds(CollectionDataStore.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(FishingTrackerApp.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: david.pu...@jjmtechcorp.com <david.pu...@jjmtechcorp.com>* > > *Phone: 508.972.1266* > > > > > > ------------------------------------------------------------------------------ > > _______________________________________________ > GeoTools-GT2-Users mailing list > GeoTools-GT2-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > > > > > > -- > > Ian Turton > > > ------------------------------------------------------------------------------ > > _______________________________________________ > GeoTools-GT2-Users mailing list > GeoTools-GT2-Users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users > > -- Ian Turton
------------------------------------------------------------------------------
_______________________________________________ GeoTools-GT2-Users mailing list GeoTools-GT2-Users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users