Search in sources :

Example 1 with AddressDetails

use of org.geotoolkit.xal.model.AddressDetails in project geotoolkit by Geomatys.

the class KmlReader method readFolder.

private Feature readFolder() throws XMLStreamException, KmlException, URISyntaxException {
    // AbstractObject
    List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
    IdAttributes idAttributes = readIdAttributes();
    // AbstractFeature
    String name = null;
    boolean visibility = DEF_VISIBILITY;
    boolean open = DEF_OPEN;
    AtomPersonConstruct author = null;
    AtomLink link = null;
    String address = null;
    AddressDetails addressDetails = null;
    String phoneNumber = null;
    Object snippet = null;
    Object description = null;
    AbstractView view = null;
    AbstractTimePrimitive timePrimitive = null;
    URI styleUrl = null;
    List<AbstractStyleSelector> styleSelector = new ArrayList<>();
    Region region = null;
    Object extendedData = null;
    List<SimpleTypeContainer> featureSimpleExtensions = new ArrayList<>();
    List<Object> featureObjectExtensions = new ArrayList<>();
    // Container
    List<SimpleTypeContainer> abstractContainerSimpleExtensions = new ArrayList<>();
    List<Object> abstractContainerObjectExtensions = new ArrayList<>();
    // Folder
    List<Feature> features = new ArrayList<>();
    List<SimpleTypeContainer> folderSimpleExtensions = new ArrayList<>();
    List<Object> folderObjectExtensions = new ArrayList<>();
    boucle: while (reader.hasNext()) {
        switch(reader.next()) {
            case XMLStreamConstants.START_ELEMENT:
                {
                    final String eName = reader.getLocalName();
                    final String eUri = reader.getNamespaceURI();
                    if (equalsNamespace(eUri)) {
                        switch(eName) {
                            case TAG_NAME:
                                name = reader.getElementText();
                                break;
                            case TAG_VISIBILITY:
                                visibility = parseBoolean(reader.getElementText());
                                break;
                            case TAG_OPEN:
                                open = parseBoolean(reader.getElementText());
                                break;
                            case TAG_ADDRESS:
                                address = reader.getElementText();
                                break;
                            case TAG_PHONE_NUMBER:
                                phoneNumber = reader.getElementText();
                                break;
                            case TAG_SNIPPET:
                                snippet = readElementText();
                                break;
                            case TAG_SNIPPET_BIG:
                                snippet = readSnippet();
                                break;
                            case TAG_DESCRIPTION:
                                description = readElementText();
                                break;
                            case TAG_STYLE_URL:
                                styleUrl = new URI(reader.getElementText());
                                break;
                            case TAG_REGION:
                                region = readRegion();
                                break;
                            case TAG_EXTENDED_DATA:
                                extendedData = readExtendedData();
                                break;
                            case TAG_META_DATA:
                                extendedData = readMetaData();
                                break;
                            default:
                                {
                                    if (isAbstractFeature(eName)) {
                                        features.add(readAbstractFeature(eName));
                                    } else if (isAbstractStyleSelector(eName)) {
                                        styleSelector.add(readAbstractStyleSelector(eName));
                                    } else if (isAbstractView(eName)) {
                                        view = readAbstractView(eName);
                                    } else if (isAbstractTimePrimitive(eName)) {
                                        timePrimitive = readAbstractTimePrimitive(eName);
                                    }
                                    break;
                                }
                        }
                    } else // ATOM
                    if (URI_ATOM.equals(eUri)) {
                        checkVersion(URI_KML_2_2);
                        // ABSTRACT FEATURE
                        if (TAG_ATOM_AUTHOR.equals(eName)) {
                            author = readAtomPersonConstruct();
                        } else if (TAG_ATOM_LINK.equals(eName)) {
                            link = readAtomLink();
                        }
                    } else // XAL
                    if (URI_XAL.equals(eUri)) {
                        checkVersion(URI_KML_2_2);
                        // ABSTRACT FEATURE
                        if (TAG_XAL_ADDRESS_DETAILS.equals(eName)) {
                            addressDetails = readXalAddressDetails();
                        }
                    } else // EXTENSIONS
                    {
                        KmlExtensionReader r;
                        if ((r = this.getComplexExtensionReader(TAG_FOLDER, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_FOLDER, eUri, eName);
                            Object ext = result.getKey();
                            Extensions.Names extensionLevel = result.getValue();
                            if (Extensions.Names.FEATURE.equals(extensionLevel)) {
                                featureObjectExtensions.add(ext);
                            } else if (Extensions.Names.CONTAINER.equals(extensionLevel)) {
                                abstractContainerObjectExtensions.add(ext);
                            } else if (Extensions.Names.FOLDER.equals(extensionLevel)) {
                                folderObjectExtensions.add(ext);
                            } else if (extensionLevel == null) {
                                if (ext instanceof Feature) {
                                    features.add((Feature) ext);
                                }
                            }
                        } else if ((r = getSimpleExtensionReader(TAG_FOLDER, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_FOLDER, eUri, eName);
                            Object ext = result.getKey();
                            Extensions.Names extensionLevel = result.getValue();
                            if (Extensions.Names.OBJECT.equals(extensionLevel)) {
                                objectSimpleExtensions.add((SimpleTypeContainer) ext);
                            } else if (Extensions.Names.FEATURE.equals(extensionLevel)) {
                                featureSimpleExtensions.add((SimpleTypeContainer) ext);
                            } else if (Extensions.Names.CONTAINER.equals(extensionLevel)) {
                                abstractContainerSimpleExtensions.add((SimpleTypeContainer) ext);
                            } else if (Extensions.Names.FOLDER.equals(extensionLevel)) {
                                folderSimpleExtensions.add((SimpleTypeContainer) ext);
                            }
                        }
                    }
                    break;
                }
            case XMLStreamConstants.END_ELEMENT:
                {
                    if (TAG_FOLDER.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
                        break boucle;
                    }
                    break;
                }
        }
    }
    return KmlReader.KML_FACTORY.createFolder(objectSimpleExtensions, idAttributes, name, visibility, open, author, link, address, addressDetails, phoneNumber, snippet, description, view, timePrimitive, styleUrl, styleSelector, region, extendedData, featureSimpleExtensions, featureObjectExtensions, abstractContainerSimpleExtensions, abstractContainerObjectExtensions, features, folderSimpleExtensions, folderObjectExtensions);
}
Also used : AbstractTimePrimitive(org.geotoolkit.data.kml.model.AbstractTimePrimitive) AtomLink(org.geotoolkit.atom.model.AtomLink) ArrayList(java.util.ArrayList) LineString(org.geotoolkit.data.kml.model.LineString) SimpleTypeContainer(org.geotoolkit.data.kml.xsd.SimpleTypeContainer) Extensions(org.geotoolkit.data.kml.model.Extensions) URI(java.net.URI) Feature(org.opengis.feature.Feature) IdAttributes(org.geotoolkit.data.kml.model.IdAttributes) AtomPersonConstruct(org.geotoolkit.atom.model.AtomPersonConstruct) Entry(java.util.Map.Entry) AbstractView(org.geotoolkit.data.kml.model.AbstractView) AddressDetails(org.geotoolkit.xal.model.AddressDetails) AbstractStyleSelector(org.geotoolkit.data.kml.model.AbstractStyleSelector) Region(org.geotoolkit.data.kml.model.Region)

Example 2 with AddressDetails

use of org.geotoolkit.xal.model.AddressDetails in project geotoolkit by Geomatys.

the class KmlReader method readPlacemark.

private Feature readPlacemark() throws XMLStreamException, KmlException, URISyntaxException {
    // AbstractObject
    List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<SimpleTypeContainer>();
    IdAttributes idAttributes = readIdAttributes();
    // AbstractFeature
    String name = null;
    boolean visibility = DEF_VISIBILITY;
    boolean open = DEF_OPEN;
    AtomPersonConstruct author = null;
    AtomLink link = null;
    String address = null;
    AddressDetails addressDetails = null;
    String phoneNumber = null;
    Object snippet = null;
    Object description = null;
    AbstractView view = null;
    AbstractTimePrimitive timePrimitive = null;
    URI styleUrl = null;
    List<AbstractStyleSelector> styleSelector = new ArrayList<AbstractStyleSelector>();
    Region region = null;
    Object extendedData = null;
    List<SimpleTypeContainer> featureSimpleExtensions = new ArrayList<SimpleTypeContainer>();
    List<Object> featureObjectExtensions = new ArrayList<Object>();
    // Placemark
    AbstractGeometry abstractGeometry = null;
    List<SimpleTypeContainer> placemarkSimpleExtensions = new ArrayList<SimpleTypeContainer>();
    List<Object> placemarkObjectExtensions = new ArrayList<Object>();
    boucle: while (reader.hasNext()) {
        switch(reader.next()) {
            case XMLStreamConstants.START_ELEMENT:
                final String eName = reader.getLocalName();
                final String eUri = reader.getNamespaceURI();
                // KML
                if (equalsNamespace(eUri)) {
                    switch(eName) {
                        case TAG_NAME:
                            name = reader.getElementText();
                            break;
                        case TAG_VISIBILITY:
                            visibility = parseBoolean(reader.getElementText());
                            break;
                        case TAG_OPEN:
                            open = parseBoolean(reader.getElementText());
                            break;
                        case TAG_ADDRESS:
                            address = reader.getElementText();
                            break;
                        case TAG_PHONE_NUMBER:
                            phoneNumber = reader.getElementText();
                            break;
                        case TAG_SNIPPET:
                            snippet = readElementText();
                            break;
                        case TAG_SNIPPET_BIG:
                            snippet = readSnippet();
                            break;
                        case TAG_DESCRIPTION:
                            description = readElementText();
                            break;
                        case TAG_STYLE_URL:
                            styleUrl = new URI(reader.getElementText());
                            break;
                        case TAG_REGION:
                            region = readRegion();
                            break;
                        case TAG_EXTENDED_DATA:
                            extendedData = readExtendedData();
                            break;
                        case TAG_META_DATA:
                            extendedData = readMetaData();
                            break;
                        default:
                            {
                                if (isAbstractView(eName)) {
                                    view = readAbstractView(eName);
                                } else if (isAbstractStyleSelector(eName)) {
                                    styleSelector.add(readAbstractStyleSelector(eName));
                                } else if (isAbstractTimePrimitive(eName)) {
                                    timePrimitive = readAbstractTimePrimitive(eName);
                                } else if (isAbstractGeometry(eName)) {
                                    abstractGeometry = readAbstractGeometry(eName);
                                }
                                break;
                            }
                    }
                } else // ATOM
                if (URI_ATOM.equals(eUri)) {
                    checkVersion(URI_KML_2_2);
                    // ABSTRACT FEATURE
                    if (TAG_ATOM_AUTHOR.equals(eName)) {
                        author = readAtomPersonConstruct();
                    } else if (TAG_ATOM_LINK.equals(eName)) {
                        link = readAtomLink();
                    }
                } else // XAL
                if (URI_XAL.equals(eUri)) {
                    checkVersion(URI_KML_2_2);
                    // ABSTRACT FEATURE
                    if (TAG_XAL_ADDRESS_DETAILS.equals(eName)) {
                        addressDetails = readXalAddressDetails();
                    }
                } else // EXTENSIONS
                {
                    KmlExtensionReader r;
                    if ((r = this.getComplexExtensionReader(TAG_PLACEMARK, eUri, eName)) != null) {
                        Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_PLACEMARK, eUri, eName);
                        Object ext = result.getKey();
                        Extensions.Names extensionLevel = result.getValue();
                        if (Extensions.Names.FEATURE.equals(extensionLevel)) {
                            featureObjectExtensions.add(ext);
                        } else if (Extensions.Names.PLACEMARK.equals(extensionLevel)) {
                            placemarkObjectExtensions.add(ext);
                        } else if (extensionLevel == null) {
                            if (ext instanceof AbstractGeometry) {
                                abstractGeometry = (AbstractGeometry) ext;
                            }
                        }
                    } else if ((r = getSimpleExtensionReader(TAG_PLACEMARK, eUri, eName)) != null) {
                        Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_PLACEMARK, eUri, eName);
                        Object ext = result.getKey();
                        Extensions.Names extensionLevel = result.getValue();
                        if (Extensions.Names.OBJECT.equals(extensionLevel)) {
                            objectSimpleExtensions.add((SimpleTypeContainer) ext);
                        } else if (Extensions.Names.FEATURE.equals(extensionLevel)) {
                            featureSimpleExtensions.add((SimpleTypeContainer) ext);
                        } else if (Extensions.Names.PLACEMARK.equals(extensionLevel)) {
                            placemarkSimpleExtensions.add((SimpleTypeContainer) ext);
                        }
                    }
                }
                break;
            case XMLStreamConstants.END_ELEMENT:
                if (TAG_PLACEMARK.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
                    break boucle;
                }
                break;
        }
    }
    return KmlReader.KML_FACTORY.createPlacemark(objectSimpleExtensions, idAttributes, name, visibility, open, author, link, address, addressDetails, phoneNumber, snippet, description, view, timePrimitive, styleUrl, styleSelector, region, extendedData, featureSimpleExtensions, featureObjectExtensions, abstractGeometry, placemarkSimpleExtensions, placemarkObjectExtensions);
}
Also used : AbstractView(org.geotoolkit.data.kml.model.AbstractView) AbstractGeometry(org.geotoolkit.data.kml.model.AbstractGeometry) AbstractTimePrimitive(org.geotoolkit.data.kml.model.AbstractTimePrimitive) AddressDetails(org.geotoolkit.xal.model.AddressDetails) AtomLink(org.geotoolkit.atom.model.AtomLink) ArrayList(java.util.ArrayList) LineString(org.geotoolkit.data.kml.model.LineString) SimpleTypeContainer(org.geotoolkit.data.kml.xsd.SimpleTypeContainer) Extensions(org.geotoolkit.data.kml.model.Extensions) URI(java.net.URI) AbstractStyleSelector(org.geotoolkit.data.kml.model.AbstractStyleSelector) IdAttributes(org.geotoolkit.data.kml.model.IdAttributes) AtomPersonConstruct(org.geotoolkit.atom.model.AtomPersonConstruct) Entry(java.util.Map.Entry) Region(org.geotoolkit.data.kml.model.Region)

Example 3 with AddressDetails

use of org.geotoolkit.xal.model.AddressDetails in project geotoolkit by Geomatys.

the class KmlReader method readNetworkLink.

private Feature readNetworkLink() throws XMLStreamException, KmlException, URISyntaxException {
    // AbstractObject
    List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
    IdAttributes idAttributes = readIdAttributes();
    // AbstractFeature
    String name = null;
    boolean visibility = DEF_VISIBILITY;
    boolean open = DEF_OPEN;
    AtomPersonConstruct author = null;
    AtomLink atomLink = null;
    String address = null;
    AddressDetails addressDetails = null;
    String phoneNumber = null;
    Object snippet = null;
    Object description = null;
    AbstractView view = null;
    AbstractTimePrimitive timePrimitive = null;
    URI styleUrl = null;
    List<AbstractStyleSelector> styleSelector = new ArrayList<>();
    Region region = null;
    Object extendedData = null;
    List<SimpleTypeContainer> featureSimpleExtensions = new ArrayList<>();
    List<Object> featureObjectExtensions = new ArrayList<>();
    // NetworkLink
    boolean refreshVisibility = DEF_REFRESH_VISIBILITY;
    boolean flyToView = DEF_FLY_TO_VIEW;
    Link link = null;
    List<SimpleTypeContainer> networkLinkSimpleExtensions = new ArrayList<>();
    List<Object> networkLinkObjectExtensions = new ArrayList<>();
    boucle: while (reader.hasNext()) {
        switch(reader.next()) {
            case XMLStreamConstants.START_ELEMENT:
                {
                    final String eName = reader.getLocalName();
                    final String eUri = reader.getNamespaceURI();
                    if (equalsNamespace(eUri)) {
                        switch(eName) {
                            case TAG_NAME:
                                name = reader.getElementText();
                                break;
                            case TAG_VISIBILITY:
                                visibility = parseBoolean(reader.getElementText());
                                break;
                            case TAG_OPEN:
                                open = parseBoolean(reader.getElementText());
                                break;
                            case TAG_ADDRESS:
                                address = reader.getElementText();
                                break;
                            case TAG_PHONE_NUMBER:
                                phoneNumber = reader.getElementText();
                                break;
                            case TAG_SNIPPET:
                                snippet = readElementText();
                                break;
                            case TAG_SNIPPET_BIG:
                                snippet = readSnippet();
                                break;
                            case TAG_DESCRIPTION:
                                description = readElementText();
                                break;
                            case TAG_STYLE_URL:
                                styleUrl = new URI(reader.getElementText());
                                break;
                            case TAG_REGION:
                                region = readRegion();
                                break;
                            case TAG_EXTENDED_DATA:
                                extendedData = readExtendedData();
                                break;
                            case TAG_META_DATA:
                                extendedData = readMetaData();
                                break;
                            case TAG_REFRESH_VISIBILITY:
                                refreshVisibility = parseBoolean(reader.getElementText());
                                break;
                            case TAG_FLY_TO_VIEW:
                                flyToView = parseBoolean(reader.getElementText());
                                break;
                            case TAG_LINK:
                                link = readLink(eName);
                                break;
                            case TAG_URL:
                                link = readUrl(eName);
                                break;
                            default:
                                {
                                    if (isAbstractView(eName)) {
                                        view = readAbstractView(eName);
                                    } else if (isAbstractStyleSelector(eName)) {
                                        styleSelector.add(readAbstractStyleSelector(eName));
                                    } else if (isAbstractTimePrimitive(eName)) {
                                        timePrimitive = readAbstractTimePrimitive(eName);
                                    }
                                    break;
                                }
                        }
                    } else // ATOM
                    if (URI_ATOM.equals(eUri)) {
                        checkVersion(URI_KML_2_2);
                        // ABSTRACT FEATURE
                        if (TAG_ATOM_AUTHOR.equals(eName)) {
                            author = readAtomPersonConstruct();
                        } else if (TAG_ATOM_LINK.equals(eName)) {
                            atomLink = readAtomLink();
                        }
                    } else // XAL
                    if (URI_XAL.equals(eUri)) {
                        checkVersion(URI_KML_2_2);
                        // ABSTRACT FEATURE
                        if (TAG_XAL_ADDRESS_DETAILS.equals(eName)) {
                            addressDetails = readXalAddressDetails();
                        }
                    } else // EXTENSIONS
                    {
                        KmlExtensionReader r;
                        if ((r = this.getComplexExtensionReader(TAG_NETWORK_LINK, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_NETWORK_LINK, eUri, eName);
                            Object ext = result.getKey();
                            Extensions.Names extensionLevel = result.getValue();
                            if (Extensions.Names.FEATURE.equals(extensionLevel)) {
                                featureObjectExtensions.add(ext);
                            } else if (Extensions.Names.NETWORK_LINK.equals(extensionLevel)) {
                                networkLinkObjectExtensions.add(ext);
                            }
                        } else if ((r = getSimpleExtensionReader(TAG_NETWORK_LINK, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_NETWORK_LINK, eUri, eName);
                            Object ext = result.getKey();
                            Extensions.Names extensionLevel = result.getValue();
                            if (Extensions.Names.OBJECT.equals(extensionLevel)) {
                                objectSimpleExtensions.add((SimpleTypeContainer) ext);
                            } else if (Extensions.Names.FEATURE.equals(extensionLevel)) {
                                featureSimpleExtensions.add((SimpleTypeContainer) ext);
                            } else if (Extensions.Names.NETWORK_LINK.equals(extensionLevel)) {
                                networkLinkSimpleExtensions.add((SimpleTypeContainer) ext);
                            }
                        }
                    }
                    break;
                }
            case XMLStreamConstants.END_ELEMENT:
                {
                    if (TAG_NETWORK_LINK.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
                        break boucle;
                    }
                    break;
                }
        }
    }
    return KmlReader.KML_FACTORY.createNetworkLink(objectSimpleExtensions, idAttributes, name, visibility, open, author, atomLink, address, addressDetails, phoneNumber, snippet, description, view, timePrimitive, styleUrl, styleSelector, region, extendedData, featureSimpleExtensions, featureObjectExtensions, refreshVisibility, flyToView, link, networkLinkSimpleExtensions, networkLinkObjectExtensions);
}
Also used : AbstractView(org.geotoolkit.data.kml.model.AbstractView) AbstractTimePrimitive(org.geotoolkit.data.kml.model.AbstractTimePrimitive) AddressDetails(org.geotoolkit.xal.model.AddressDetails) AtomLink(org.geotoolkit.atom.model.AtomLink) ArrayList(java.util.ArrayList) LineString(org.geotoolkit.data.kml.model.LineString) SimpleTypeContainer(org.geotoolkit.data.kml.xsd.SimpleTypeContainer) Extensions(org.geotoolkit.data.kml.model.Extensions) URI(java.net.URI) AbstractStyleSelector(org.geotoolkit.data.kml.model.AbstractStyleSelector) IdAttributes(org.geotoolkit.data.kml.model.IdAttributes) AtomPersonConstruct(org.geotoolkit.atom.model.AtomPersonConstruct) Entry(java.util.Map.Entry) Region(org.geotoolkit.data.kml.model.Region) AtomLink(org.geotoolkit.atom.model.AtomLink) Link(org.geotoolkit.data.kml.model.Link) BasicLink(org.geotoolkit.data.kml.model.BasicLink)

Example 4 with AddressDetails

use of org.geotoolkit.xal.model.AddressDetails in project geotoolkit by Geomatys.

the class KmlReader method readGroundOverlay.

private Feature readGroundOverlay() throws XMLStreamException, KmlException, URISyntaxException {
    // AbstractObject
    List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
    IdAttributes idAttributes = readIdAttributes();
    // AbstractFeature
    String name = null;
    boolean visibility = DEF_VISIBILITY;
    boolean open = DEF_OPEN;
    AtomPersonConstruct author = null;
    AtomLink link = null;
    String address = null;
    AddressDetails addressDetails = null;
    String phoneNumber = null;
    Object snippet = null;
    Object description = null;
    AbstractView view = null;
    AbstractTimePrimitive timePrimitive = null;
    URI styleUrl = null;
    List<AbstractStyleSelector> styleSelector = new ArrayList<>();
    Region region = null;
    Object extendedData = null;
    List<SimpleTypeContainer> featureSimpleExtensions = new ArrayList<>();
    List<Object> featureObjectExtensions = new ArrayList<>();
    // AbstractOverlay
    Color color = DEF_COLOR;
    int drawOrder = DEF_DRAW_ORDER;
    Icon icon = null;
    List<SimpleTypeContainer> abstractOverlaySimpleExtensions = new ArrayList<>();
    List<Object> abstractOverlayObjectExtensions = new ArrayList<>();
    // GroundOverlay
    double altitude = DEF_ALTITUDE;
    AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
    LatLonBox latLonBox = null;
    List<SimpleTypeContainer> groundOverlaySimpleExtensions = new ArrayList<>();
    List<Object> groundOverlayObjectExtensions = new ArrayList<>();
    boucle: while (reader.hasNext()) {
        switch(reader.next()) {
            case XMLStreamConstants.START_ELEMENT:
                {
                    final String eName = reader.getLocalName();
                    final String eUri = reader.getNamespaceURI();
                    // KML
                    if (equalsNamespace(eUri)) {
                        switch(eName) {
                            case TAG_NAME:
                                name = reader.getElementText();
                                break;
                            case TAG_VISIBILITY:
                                visibility = parseBoolean(reader.getElementText());
                                break;
                            case TAG_OPEN:
                                open = parseBoolean(reader.getElementText());
                                break;
                            case TAG_ADDRESS:
                                address = reader.getElementText();
                                break;
                            case TAG_PHONE_NUMBER:
                                phoneNumber = reader.getElementText();
                                break;
                            case TAG_SNIPPET:
                                snippet = readElementText();
                                break;
                            case TAG_SNIPPET_BIG:
                                snippet = readSnippet();
                                break;
                            case TAG_DESCRIPTION:
                                description = readElementText();
                                break;
                            case TAG_STYLE_URL:
                                styleUrl = new URI(reader.getElementText());
                                break;
                            case TAG_REGION:
                                region = readRegion();
                                break;
                            case TAG_EXTENDED_DATA:
                                extendedData = readExtendedData();
                                break;
                            case TAG_META_DATA:
                                extendedData = readMetaData();
                                break;
                            case TAG_COLOR:
                                color = KmlUtilities.parseColor(reader.getElementText());
                                break;
                            case TAG_DRAW_ORDER:
                                drawOrder = Integer.parseInt(reader.getElementText());
                                break;
                            case TAG_ICON:
                                icon = readIcon(eName);
                                break;
                            case TAG_ALTITUDE:
                                altitude = parseDouble(reader.getElementText());
                                break;
                            case TAG_ALTITUDE_MODE:
                                altitudeMode = readAltitudeMode();
                                break;
                            case TAG_LAT_LON_BOX:
                                latLonBox = readLatLonBox();
                                break;
                            default:
                                {
                                    if (isAbstractView(eName)) {
                                        view = readAbstractView(eName);
                                    } else if (isAbstractTimePrimitive(eName)) {
                                        timePrimitive = readAbstractTimePrimitive(eName);
                                    } else if (isAbstractStyleSelector(eName)) {
                                        styleSelector.add(readAbstractStyleSelector(eName));
                                    }
                                    break;
                                }
                        }
                    } else if (URI_ATOM.equals(eUri)) {
                        checkVersion(URI_KML_2_2);
                        // ABSTRACT FEATURE
                        if (TAG_ATOM_AUTHOR.equals(eName)) {
                            author = readAtomPersonConstruct();
                        } else if (TAG_ATOM_LINK.equals(eName)) {
                            link = readAtomLink();
                        }
                    } else if (URI_XAL.equals(eUri)) {
                        checkVersion(URI_KML_2_2);
                        // ABSTRACT FEATURE
                        if (TAG_XAL_ADDRESS_DETAILS.equals(eName)) {
                            addressDetails = readXalAddressDetails();
                        }
                    } else // EXTENSIONS
                    {
                        KmlExtensionReader r;
                        if ((r = this.getComplexExtensionReader(TAG_GROUND_OVERLAY, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_GROUND_OVERLAY, eUri, eName);
                            Object ext = result.getKey();
                            Extensions.Names extensionLevel = result.getValue();
                            if (Extensions.Names.FEATURE.equals(extensionLevel)) {
                                featureObjectExtensions.add(ext);
                            } else if (Extensions.Names.OVERLAY.equals(extensionLevel)) {
                                abstractOverlayObjectExtensions.add(ext);
                            } else if (Extensions.Names.GROUND_OVERLAY.equals(extensionLevel)) {
                                groundOverlayObjectExtensions.add(ext);
                            } else if (extensionLevel == null) {
                                if (ext instanceof AltitudeMode) {
                                    altitudeMode = (AltitudeMode) ext;
                                }
                            }
                        } else if ((r = getSimpleExtensionReader(TAG_GROUND_OVERLAY, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_GROUND_OVERLAY, eUri, eName);
                            Object ext = result.getKey();
                            Extensions.Names extensionLevel = result.getValue();
                            if (Extensions.Names.OBJECT.equals(extensionLevel)) {
                                objectSimpleExtensions.add((SimpleTypeContainer) ext);
                            } else if (Extensions.Names.FEATURE.equals(extensionLevel)) {
                                featureSimpleExtensions.add((SimpleTypeContainer) ext);
                            } else if (Extensions.Names.OVERLAY.equals(extensionLevel)) {
                                abstractOverlaySimpleExtensions.add((SimpleTypeContainer) ext);
                            } else if (Extensions.Names.GROUND_OVERLAY.equals(extensionLevel)) {
                                groundOverlaySimpleExtensions.add((SimpleTypeContainer) ext);
                            }
                        }
                    }
                    break;
                }
            case XMLStreamConstants.END_ELEMENT:
                {
                    if (TAG_GROUND_OVERLAY.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
                        break boucle;
                    }
                    break;
                }
        }
    }
    return KmlReader.KML_FACTORY.createGroundOverlay(objectSimpleExtensions, idAttributes, name, visibility, open, author, link, address, addressDetails, phoneNumber, snippet, description, view, timePrimitive, styleUrl, styleSelector, region, extendedData, featureSimpleExtensions, featureObjectExtensions, color, drawOrder, icon, abstractOverlaySimpleExtensions, abstractOverlayObjectExtensions, altitude, altitudeMode, latLonBox, groundOverlaySimpleExtensions, groundOverlayObjectExtensions);
}
Also used : AbstractTimePrimitive(org.geotoolkit.data.kml.model.AbstractTimePrimitive) AtomLink(org.geotoolkit.atom.model.AtomLink) ArrayList(java.util.ArrayList) LineString(org.geotoolkit.data.kml.model.LineString) SimpleTypeContainer(org.geotoolkit.data.kml.xsd.SimpleTypeContainer) EnumAltitudeMode(org.geotoolkit.data.kml.model.EnumAltitudeMode) AltitudeMode(org.geotoolkit.data.kml.model.AltitudeMode) Extensions(org.geotoolkit.data.kml.model.Extensions) URI(java.net.URI) IdAttributes(org.geotoolkit.data.kml.model.IdAttributes) AtomPersonConstruct(org.geotoolkit.atom.model.AtomPersonConstruct) Entry(java.util.Map.Entry) AbstractView(org.geotoolkit.data.kml.model.AbstractView) AddressDetails(org.geotoolkit.xal.model.AddressDetails) Color(java.awt.Color) LatLonBox(org.geotoolkit.data.kml.model.LatLonBox) AbstractLatLonBox(org.geotoolkit.data.kml.model.AbstractLatLonBox) AbstractStyleSelector(org.geotoolkit.data.kml.model.AbstractStyleSelector) Point(org.geotoolkit.data.kml.model.Point) Region(org.geotoolkit.data.kml.model.Region) Icon(org.geotoolkit.data.kml.model.Icon) ItemIcon(org.geotoolkit.data.kml.model.ItemIcon)

Example 5 with AddressDetails

use of org.geotoolkit.xal.model.AddressDetails in project geotoolkit by Geomatys.

the class AddressTest method addressReadTest.

@Test
public void addressReadTest() throws IOException, XMLStreamException, XalException {
    final XalReader reader = new XalReader();
    reader.setInput(new File(pathToTestFile));
    final Xal xalObjects = reader.read();
    reader.dispose();
    assertEquals("v", xalObjects.getVersion());
    assertEquals(1, xalObjects.getAddressDetails().size());
    final AddressDetails addressDetails0 = xalObjects.getAddressDetails().get(0);
    assertEquals("addressType", addressDetails0.getAddressType());
    assertEquals("currentStatus", addressDetails0.getCurrentStatus());
    assertEquals("validFrom", addressDetails0.getValidFromDate());
    assertEquals("validTo", addressDetails0.getValidToDate());
    assertEquals("usage", addressDetails0.getUsage());
    assertEquals("code", addressDetails0.getGrPostal().getCode());
    assertEquals("key", addressDetails0.getAddressDetailsKey());
    final PostalServiceElements postalServiceElements = addressDetails0.getPostalServiceElements();
    assertEquals("typePostalServiceElement", postalServiceElements.getType());
    assertEquals(2, postalServiceElements.getAddressIdentifiers().size());
    final AddressIdentifier addressIdentifier0 = postalServiceElements.getAddressIdentifiers().get(0);
    assertEquals("code34", addressIdentifier0.getGrPostal().getCode());
    assertEquals("identifierType34", addressIdentifier0.getIdentifierType());
    assertEquals("type34", addressIdentifier0.getType());
    assertEquals("Hérault", addressIdentifier0.getContent());
    final AddressIdentifier addressIdentifier1 = postalServiceElements.getAddressIdentifiers().get(1);
    assertEquals("code11", addressIdentifier1.getGrPostal().getCode());
    assertEquals("identifierType11", addressIdentifier1.getIdentifierType());
    assertEquals("type11", addressIdentifier1.getType());
    assertEquals("Aude", addressIdentifier1.getContent());
    final GenericTypedGrPostal endorsementLineCode = postalServiceElements.getEndorsementLineCode();
    assertEquals("code30", endorsementLineCode.getGrPostal().getCode());
    assertEquals("type30", endorsementLineCode.getType());
    assertEquals("Gard", endorsementLineCode.getContent());
    final GenericTypedGrPostal keyLineCode = postalServiceElements.getKeyLineCode();
    assertEquals("code64", keyLineCode.getGrPostal().getCode());
    assertEquals("type64", keyLineCode.getType());
    assertEquals("Pyrénées Atlantiques", keyLineCode.getContent());
    final GenericTypedGrPostal barCode = postalServiceElements.getBarcode();
    assertEquals("code66", barCode.getGrPostal().getCode());
    assertEquals("type66", barCode.getType());
    assertEquals("Pyrénées Orientales", barCode.getContent());
    final SortingCode sortingCode = postalServiceElements.getSortingCode();
    assertEquals("codeSortingCode", sortingCode.getGrPostal().getCode());
    assertEquals("typeSortingCode", sortingCode.getType());
    final GenericTypedGrPostal addressLatitude = postalServiceElements.getAddressLatitude();
    assertEquals("codeAddressLatitude", addressLatitude.getGrPostal().getCode());
    assertEquals("typeAddressLatitude", addressLatitude.getType());
    assertEquals("Latitude", addressLatitude.getContent());
    final GenericTypedGrPostal addressLatitudeDirection = postalServiceElements.getAddressLatitudeDirection();
    assertEquals("codeLatitudeDirection", addressLatitudeDirection.getGrPostal().getCode());
    assertEquals("typeLatitudeDirection", addressLatitudeDirection.getType());
    assertEquals("LatitudeDirection", addressLatitudeDirection.getContent());
    final GenericTypedGrPostal addressLongitude = postalServiceElements.getAddressLongitude();
    assertEquals("codeLongitude", addressLongitude.getGrPostal().getCode());
    assertEquals("typeLongitude", addressLongitude.getType());
    assertEquals("Longitude", addressLongitude.getContent());
    final GenericTypedGrPostal addressLongitudeDirection = postalServiceElements.getAddressLongitudeDirection();
    assertEquals("codeLongitudeDirection", addressLongitudeDirection.getGrPostal().getCode());
    assertEquals("typeLongitudeDirection", addressLongitudeDirection.getType());
    assertEquals("LongitudeDirection", addressLongitudeDirection.getContent());
    assertEquals(2, postalServiceElements.getSupplementaryPostalServiceData().size());
    final GenericTypedGrPostal sps1 = postalServiceElements.getSupplementaryPostalServiceData().get(0);
    assertEquals("codeSPS1", sps1.getGrPostal().getCode());
    assertEquals("typeSPS1", sps1.getType());
    assertEquals("First supplementary postal service data", sps1.getContent());
    final GenericTypedGrPostal sps2 = postalServiceElements.getSupplementaryPostalServiceData().get(1);
    assertEquals("codeSPS2", sps2.getGrPostal().getCode());
    assertEquals("typeSPS2", sps2.getType());
    assertEquals("Second supplementary postal service data", sps2.getContent());
    final GenericTypedGrPostal address = addressDetails0.getAddress();
    assertEquals("addressCode", address.getGrPostal().getCode());
    assertEquals("addressType", address.getType());
    assertEquals("Une adresse", address.getContent());
}
Also used : PostalServiceElements(org.geotoolkit.xal.model.PostalServiceElements) Xal(org.geotoolkit.xal.model.Xal) XalReader(org.geotoolkit.xal.xml.XalReader) AddressDetails(org.geotoolkit.xal.model.AddressDetails) AddressIdentifier(org.geotoolkit.xal.model.AddressIdentifier) GenericTypedGrPostal(org.geotoolkit.xal.model.GenericTypedGrPostal) File(java.io.File) SortingCode(org.geotoolkit.xal.model.SortingCode) Test(org.junit.Test)

Aggregations

AddressDetails (org.geotoolkit.xal.model.AddressDetails)20 File (java.io.File)12 Xal (org.geotoolkit.xal.model.Xal)12 Test (org.junit.Test)12 URI (java.net.URI)8 ArrayList (java.util.ArrayList)8 AtomLink (org.geotoolkit.atom.model.AtomLink)8 AtomPersonConstruct (org.geotoolkit.atom.model.AtomPersonConstruct)8 AbstractStyleSelector (org.geotoolkit.data.kml.model.AbstractStyleSelector)8 AbstractTimePrimitive (org.geotoolkit.data.kml.model.AbstractTimePrimitive)8 AbstractView (org.geotoolkit.data.kml.model.AbstractView)8 IdAttributes (org.geotoolkit.data.kml.model.IdAttributes)8 Region (org.geotoolkit.data.kml.model.Region)8 SimpleTypeContainer (org.geotoolkit.data.kml.xsd.SimpleTypeContainer)8 GenericTypedGrPostal (org.geotoolkit.xal.model.GenericTypedGrPostal)8 Entry (java.util.Map.Entry)7 Extensions (org.geotoolkit.data.kml.model.Extensions)7 LineString (org.geotoolkit.data.kml.model.LineString)7 Locality (org.geotoolkit.xal.model.Locality)6 PostBox (org.geotoolkit.xal.model.PostBox)6