Justin,
Thanks. Adding the explicit import for that version of the KML parser
makes the appropriate data appear in the userData() method:
props:[SimpleFeatureImpl.Attribute: name<name
id=fid-6e9af07a_13f38d301ae_-7ff5>=Aung San TB,
SimpleFeatureImpl.Attribute: visibility<visibility
id=fid-6e9af07a_13f38d301ae_-7ff5>=false, SimpleFeatureImpl.Attribute:
open<open id=fid-6e9af07a_13f38d301ae_-7ff5>=true,
SimpleFeatureImpl.Attribute: address<address
id=fid-6e9af07a_13f38d301ae_-7ff5>=null, SimpleFeatureImpl.Attribute:
phoneNumber<phoneNumber id=fid-6e9af07a_13f38d301ae_-7ff5>=null,
SimpleFeatureImpl.Attribute: description<description
id=fid-6e9af07a_13f38d301ae_-7ff5>=null, SimpleFeatureImpl.Attribute:
LookAt<LookAt id=fid-6e9af07a_13f38d301ae_-7ff5>=null,
SimpleFeatureImpl.Attribute: Style<Style
id=fid-6e9af07a_13f38d301ae_-7ff5>=null, SimpleFeatureImpl.Attribute:
Region<Region id=fid-6e9af07a_13f38d301ae_-7ff5>=null,
SimpleFeatureImpl.Attribute: Geometry<Geometry
id=fid-6e9af07a_13f38d301ae_-7ff5>=POINT (96.1094 16.9165)]
attributes: [Aung San TB, false, true, null, null, null, null, null, null,
POINT (96.1094 16.9165)]
userData:{Folder=[], UntypedExtendedData={level=1, num=300,
UnitID=MMH00752, LvlID=MMP013001004000000000}}
- adam
On Wed, Jun 12, 2013 at 6:56 AM, Justin Deoliveira <[email protected]>wrote:
> Hi Adam,
>
> If you use the kml version 2.2 configuration,
> org.geotools.kml.v22.KMLConfiguration it should show up in user data of the
> feature.
>
> As for supporting it in 2.1 I don't believe extended data is supported in
> the KML 2.1 schema. But if i'm wrong feel free to open a jira. It might no
> be a bad idea regardless to support extended data in 2.1 even if its not in
> the schema.
>
> -Justin
>
>
> On Tue, Jun 11, 2013 at 6:10 PM, adam brin <[email protected]>wrote:
>
>> Does anyone know how to get at the extendedData section of a Placemark or
>> other entry in KML files? It doesn't look like getAttributes(),
>> getUserData() and getProperties(). Example KML and parser code below.
>>
>>
>> *example KML file:*
>> <?xml version="1.0" encoding="utf-8"?>
>> <kml xmlns="http://earth.google.com/kml/2.1">
>> <Document>
>> <name>Switzerland 1837</name>
>> <description></description>
>> <Style>
>> <ListStyle id="hideChildren">
>> <listItemType>checkHideChildren</listItemType>
>> </ListStyle>
>> </Style>
>> <Placemark>
>> <name>Aung San TB</name>
>> <visibility>0</visibility>
>> <Snippet maxLines="0"></Snippet>
>> <styleUrl>#adv</styleUrl>
>> <ExtendedData>
>> <Data name="level">
>> <value>1</value>
>> </Data>
>> <Data name="num">
>> <value>300</value>
>> </Data>
>> <Data name="UnitID">
>> <value>MMH00752</value>
>> </Data>
>> <Data name="LvlID">
>> <value>MMP013001004000000000</value>
>> </Data>
>> </ExtendedData>
>> <Point>
>> <coordinates>96.10939999999999,16.9165,0</coordinates>
>> </Point>
>> </Placemark>
>> </Document>
>> </kml>
>>
>> *example parser code:*
>>
>> Parser parser = new Parser(new KMLConfiguration());
>> SimpleFeature f = (SimpleFeature)
>> parser.parse(newFileInputStream(file));
>> Collection placemarks = (Collection) f.getAttribute(
>> "Feature");
>> for (Object mark : placemarks) {
>>
>> SimpleFeature feature = (SimpleFeature)mark;
>> Set<Entry<Object, Object>> entrySet =
>> feature.getUserData().entrySet();
>> getLogger().info("props:{} \n attributes: {}",
>> feature.getProperties(), feature.getAttributes());
>> getLogger().info("{}: {}", feature.getAttribute(
>> "name"), feature.getAttribute("description"));
>> }
>>
>>
>> thanks,
>>
>> adam brin
>>
>>
>> _________________________________________________________
>> Adam Brin
>> Director of Technology, Digital Antiquity
>> 480.965.1278
>>
>>
>> ------------------------------------------------------------------------------
>> This SF.net email is sponsored by Windows:
>>
>> Build for Windows Store.
>>
>> http://p.sf.net/sfu/windows-dev2dev
>> _______________________________________________
>> 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.
>
--
_________________________________________________________
Adam Brin
Director of Technology, Digital Antiquity
480.965.1278
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users