Thanks. One other follow up question. We have GeoJSON files where some
properties are complex, e.g., "C1":{"A":1,"B":2}. In this case I cannot use
SimpleFeature. Which class should I use. I have been going through the unit
tests for 2.7.0.1 and I could not find an example.
Rico
On Wed, Apr 27, 2011 at 9:52 AM, Justin Deoliveira <[email protected]>wrote:
> 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
>
>
--
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