Yeah, this is how the geojson parser works... since there is no schema or
anything it has to use the first feature to build the feature type. Feel
free to open a bug report in the tracker... might be better not to just
choke like this. Or possibly rebuild the type on the fly.
On Wed, Apr 27, 2011 at 12:36 AM, andrea antonello <
[email protected]> wrote:
> It might be because the first feature doesn't have the ALIAS attribute?
>
> Andrea
>
> On Tue, Apr 26, 2011 at 11:55 PM, Rico Lelina <[email protected]> wrote:
> > I have the following GeoJSON file:
> > {"type":"FeatureCollection",
> > "features":
> > [
> > {"type":"Feature",
> > "geometry":{"type":"Point","coordinates":[0.0, 0.0]},
> > "properties":{"NAME":"Point-0001"}
> > },
> > {"type":"Feature",
> > "geometry":{"type":"Point","coordinates":[1.0, 1.0]},
> > "properties":{"NAME":"Point-0002","ALIAS":"Point2"}
> > }
> > ]
> > }
> >
> > My code:
> > BufferedReader reader = new BufferedReader(new FileReader(srcFile));
> > FeatureJSON fjson = new FeatureJSON();
> > FeatureIterator<SimpleFeature> features =
> > fjson.streamFeatureCollection(reader);
> > while (features.hasNext()) {
> > ...
> > }
> >
> > The first feature is read just fine. But when I get to the next feature,
> I
> > get the following exception on the call to hasNext():
> > java.lang.RuntimeException: java.lang.IllegalArgumentException: No such
> > attribute:ALIAS
> > at
> >
> org.geotools.geojson.feature.FeatureJSON$FeatureCollectionIterator.readNext(FeatureJSON.java:533)
> > at
> >
> org.geotools.geojson.feature.FeatureJSON$FeatureCollectionIterator.hasNext(FeatureJSON.java:517)
> >
> > Can't I use SimpleFeature in this case? What is causing the exception?
> >
> > Thanks,
> > Rico
> >
> >
> >
> ------------------------------------------------------------------------------
> > WhatsUp Gold - Download Free Network Management Software
> > The most intuitive, comprehensive, and cost-effective network
> > management toolset available today. Delivers lowest initial
> > acquisition cost and overall TCO of any competing solution.
> > http://p.sf.net/sfu/whatsupgold-sd
> > _______________________________________________
> > Geotools-gt2-users mailing list
> > [email protected]
> > https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
> >
> >
>
>
> ------------------------------------------------------------------------------
> WhatsUp Gold - Download Free Network Management Software
> The most intuitive, comprehensive, and cost-effective network
> management toolset available today. Delivers lowest initial
> acquisition cost and overall TCO of any competing solution.
> http://p.sf.net/sfu/whatsupgold-sd
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>
--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.
------------------------------------------------------------------------------
WhatsUp Gold - Download Free Network Management Software
The most intuitive, comprehensive, and cost-effective network
management toolset available today. Delivers lowest initial
acquisition cost and overall TCO of any competing solution.
http://p.sf.net/sfu/whatsupgold-sd
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users