Search in sources :

Example 6 with AddressDetails

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

the class AddressTest method addressWriteTest.

@Test
public void addressWriteTest() throws IOException, XMLStreamException, ParserConfigurationException, SAXException, XalException {
    final XalFactory xalFactory = DefaultXalFactory.getInstance();
    final PostalServiceElements postalServiceElements = xalFactory.createPostalServiceElements();
    final AddressIdentifier addressIdentifier0 = xalFactory.createAddressIdentifier();
    addressIdentifier0.setGrPostal(xalFactory.createGrPostal("code34"));
    addressIdentifier0.setIdentifierType("identifierType34");
    addressIdentifier0.setType("type34");
    addressIdentifier0.setContent("Hérault");
    final AddressIdentifier addressIdentifier1 = xalFactory.createAddressIdentifier();
    addressIdentifier1.setGrPostal(xalFactory.createGrPostal("code11"));
    addressIdentifier1.setIdentifierType("identifierType11");
    addressIdentifier1.setType("type11");
    addressIdentifier1.setContent("Aude");
    postalServiceElements.setAddressIdentifiers(Arrays.asList(addressIdentifier0, addressIdentifier1));
    final GenericTypedGrPostal endorsementLineCode = xalFactory.createGenericTypedGrPostal();
    endorsementLineCode.setGrPostal(xalFactory.createGrPostal("code30"));
    endorsementLineCode.setType("type30");
    endorsementLineCode.setContent("Gard");
    postalServiceElements.setEndorsementLineCode(endorsementLineCode);
    final GenericTypedGrPostal keyLineCode = xalFactory.createGenericTypedGrPostal();
    keyLineCode.setGrPostal(xalFactory.createGrPostal("code64"));
    keyLineCode.setType("type64");
    keyLineCode.setContent("Pyrénées Atlantiques");
    postalServiceElements.setKeyLineCode(keyLineCode);
    final GenericTypedGrPostal barCode = xalFactory.createGenericTypedGrPostal();
    barCode.setGrPostal(xalFactory.createGrPostal("code66"));
    barCode.setType("type66");
    barCode.setContent("Pyrénées Orientales");
    postalServiceElements.setBarcode(barCode);
    final SortingCode sortingCode = xalFactory.createSortingCode("typeSortingCode", xalFactory.createGrPostal("codeSortingCode"));
    postalServiceElements.setSortingCode(sortingCode);
    final GenericTypedGrPostal addressLatitude = xalFactory.createGenericTypedGrPostal();
    addressLatitude.setGrPostal(xalFactory.createGrPostal("codeAddressLatitude"));
    addressLatitude.setType("typeAddressLatitude");
    addressLatitude.setContent("Latitude");
    postalServiceElements.setAddressLatitude(addressLatitude);
    final GenericTypedGrPostal addressLatitudeDirection = xalFactory.createGenericTypedGrPostal();
    addressLatitudeDirection.setGrPostal(xalFactory.createGrPostal("codeLatitudeDirection"));
    addressLatitudeDirection.setType("typeLatitudeDirection");
    addressLatitudeDirection.setContent("LatitudeDirection");
    postalServiceElements.setAddressLatitudeDirection(addressLatitudeDirection);
    final GenericTypedGrPostal addressLongitude = xalFactory.createGenericTypedGrPostal();
    addressLongitude.setGrPostal(xalFactory.createGrPostal("codeLongitude"));
    addressLongitude.setType("typeLongitude");
    addressLongitude.setContent("Longitude");
    postalServiceElements.setAddressLongitude(addressLongitude);
    final GenericTypedGrPostal addressLongitudeDirection = xalFactory.createGenericTypedGrPostal();
    addressLongitudeDirection.setGrPostal(xalFactory.createGrPostal("codeLongitudeDirection"));
    addressLongitudeDirection.setType("typeLongitudeDirection");
    addressLongitudeDirection.setContent("LongitudeDirection");
    postalServiceElements.setAddressLongitudeDirection(addressLongitudeDirection);
    final GenericTypedGrPostal sps1 = xalFactory.createGenericTypedGrPostal();
    sps1.setGrPostal(xalFactory.createGrPostal("codeSPS1"));
    sps1.setType("typeSPS1");
    sps1.setContent("First supplementary postal service data");
    final GenericTypedGrPostal sps2 = xalFactory.createGenericTypedGrPostal();
    sps2.setGrPostal(xalFactory.createGrPostal("codeSPS2"));
    sps2.setType("typeSPS2");
    sps2.setContent("Second supplementary postal service data");
    postalServiceElements.setSupplementaryPostalServiceData(Arrays.asList(sps1, sps2));
    postalServiceElements.setType("typePostalServiceElement");
    final GenericTypedGrPostal address = xalFactory.createGenericTypedGrPostal();
    address.setGrPostal(xalFactory.createGrPostal("addressCode"));
    address.setType("addressType");
    address.setContent("Une adresse");
    final AddressDetails addressDetails = xalFactory.createAddressDetails();
    addressDetails.setPostalServiceElements(postalServiceElements);
    addressDetails.setAddress(address);
    addressDetails.setAddressType("addressType");
    addressDetails.setCurrentStatus("currentStatus");
    addressDetails.setValidFromDate("validFrom");
    addressDetails.setValidToDate("validTo");
    addressDetails.setUsage("usage");
    addressDetails.setGrPostal(xalFactory.createGrPostal("code"));
    addressDetails.setAddressDetailsKey("key");
    final Xal xal = xalFactory.createXal(Arrays.asList(addressDetails), "v");
    final File temp = File.createTempFile("addressTest", ".xal");
    temp.deleteOnExit();
    final XalWriter writer = new XalWriter();
    writer.setOutput(temp);
    writer.write(xal);
    writer.dispose();
    DomCompare.compare(new File(pathToTestFile), temp);
}
Also used : PostalServiceElements(org.geotoolkit.xal.model.PostalServiceElements) XalWriter(org.geotoolkit.xal.xml.XalWriter) Xal(org.geotoolkit.xal.model.Xal) 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)

Example 7 with AddressDetails

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

the class KmlReader method readScreenOverlay.

private Feature readScreenOverlay() 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<>();
    // ScreenOverlay
    Vec2 overlayXY = null;
    Vec2 screenXY = null;
    Vec2 rotationXY = null;
    Vec2 size = null;
    double rotation = DEF_ROTATION;
    List<SimpleTypeContainer> screenOverlaySimpleExtensions = new ArrayList<>();
    List<Object> screenOverlayObjectExtensions = 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_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_OVERLAY_XY:
                                overlayXY = readVec2(eName);
                                break;
                            case TAG_SCREEN_XY:
                                screenXY = readVec2(eName);
                                break;
                            case TAG_ROTATION_XY:
                                rotationXY = readVec2(eName);
                                break;
                            case TAG_SIZE:
                                size = readVec2(eName);
                                break;
                            case TAG_ROTATION:
                                rotation = parseDouble(reader.getElementText());
                                break;
                            default:
                                {
                                    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_SCREEN_OVERLAY, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_SCREEN_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.SCREEN_OVERLAY.equals(extensionLevel)) {
                                screenOverlayObjectExtensions.add(ext);
                            }
                        } else if ((r = getSimpleExtensionReader(TAG_SCREEN_OVERLAY, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_SCREEN_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.SCREEN_OVERLAY.equals(extensionLevel)) {
                                screenOverlaySimpleExtensions.add((SimpleTypeContainer) ext);
                            }
                        }
                    }
                    break;
                }
            case XMLStreamConstants.END_ELEMENT:
                {
                    if (TAG_SCREEN_OVERLAY.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
                        break boucle;
                    }
                    break;
                }
        }
    }
    return KmlReader.KML_FACTORY.createScreenOverlay(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, overlayXY, screenXY, rotationXY, size, rotation, screenOverlaySimpleExtensions, screenOverlayObjectExtensions);
}
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) IdAttributes(org.geotoolkit.data.kml.model.IdAttributes) AtomPersonConstruct(org.geotoolkit.atom.model.AtomPersonConstruct) Entry(java.util.Map.Entry) Vec2(org.geotoolkit.data.kml.model.Vec2) AbstractView(org.geotoolkit.data.kml.model.AbstractView) AddressDetails(org.geotoolkit.xal.model.AddressDetails) Color(java.awt.Color) 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 8 with AddressDetails

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

the class KmlReader method readDocument.

private Feature readDocument() 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<>();
    // Document
    List<Schema> schemas = new ArrayList<>();
    List<Feature> features = new ArrayList<>();
    List<SimpleTypeContainer> documentSimpleExtensions = new ArrayList<>();
    List<Object> documentObjectExtensions = 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_SCHEMA:
                                checkVersion(URI_KML_2_2);
                                schemas.add(readSchema());
                                break;
                            default:
                                {
                                    if (isAbstractFeature(eName)) {
                                        features.add(readAbstractFeature(eName));
                                    } else if (isAbstractView(eName)) {
                                        view = readAbstractView(eName);
                                    } else if (isAbstractTimePrimitive(eName)) {
                                        timePrimitive = readAbstractTimePrimitive(eName);
                                    } else if (isAbstractStyleSelector(eName)) {
                                        styleSelector.add(readAbstractStyleSelector(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_DOCUMENT, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_DOCUMENT, 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.DOCUMENT.equals(extensionLevel)) {
                                documentObjectExtensions.add(ext);
                            } else if (extensionLevel == null) {
                                if (ext instanceof Feature) {
                                    features.add((Feature) ext);
                                }
                            }
                        } else if ((r = getSimpleExtensionReader(TAG_DOCUMENT, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_DOCUMENT, 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.DOCUMENT.equals(extensionLevel)) {
                                documentSimpleExtensions.add((SimpleTypeContainer) ext);
                            }
                        }
                    }
                    break;
                }
            case XMLStreamConstants.END_ELEMENT:
                {
                    if (TAG_DOCUMENT.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
                        break boucle;
                    }
                    break;
                }
        }
    }
    return KmlReader.KML_FACTORY.createDocument(objectSimpleExtensions, idAttributes, name, visibility, open, author, link, address, addressDetails, phoneNumber, snippet, description, view, timePrimitive, styleUrl, styleSelector, region, extendedData, featureSimpleExtensions, featureObjectExtensions, abstractContainerSimpleExtensions, abstractContainerObjectExtensions, schemas, features, documentSimpleExtensions, documentObjectExtensions);
}
Also used : AbstractTimePrimitive(org.geotoolkit.data.kml.model.AbstractTimePrimitive) AtomLink(org.geotoolkit.atom.model.AtomLink) Schema(org.geotoolkit.data.kml.model.Schema) 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 9 with AddressDetails

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

the class KmlReader method readPhotoOverlay.

private Feature readPhotoOverlay() 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<>();
    // PhotoOverlay
    double rotation = DEF_ROTATION;
    ViewVolume viewVolume = null;
    ImagePyramid imagePyramid = null;
    Point point = null;
    Shape shape = null;
    List<SimpleTypeContainer> photoOverlaySimpleExtensions = new ArrayList<>();
    List<Object> photoOverlayObjectExtensions = 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_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_ROTATION:
                                rotation = parseDouble(reader.getElementText());
                                break;
                            case TAG_VIEW_VOLUME:
                                viewVolume = readViewVolume();
                                break;
                            case TAG_IMAGE_PYRAMID:
                                imagePyramid = readImagePyramid();
                                break;
                            case TAG_POINT:
                                point = readPoint();
                                break;
                            case TAG_SHAPE:
                                shape = Shape.transform(reader.getElementText());
                                break;
                            default:
                                {
                                    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_PHOTO_OVERLAY, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_PHOTO_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.PHOTO_OVERLAY.equals(extensionLevel)) {
                                photoOverlayObjectExtensions.add(ext);
                            }
                        } else if ((r = getSimpleExtensionReader(TAG_PHOTO_OVERLAY, eUri, eName)) != null) {
                            Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_PHOTO_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.PHOTO_OVERLAY.equals(extensionLevel)) {
                                photoOverlaySimpleExtensions.add((SimpleTypeContainer) ext);
                            }
                        }
                    }
                    break;
                }
            case XMLStreamConstants.END_ELEMENT:
                {
                    if (TAG_PHOTO_OVERLAY.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
                        break boucle;
                    }
                    break;
                }
        }
    }
    return KmlReader.KML_FACTORY.createPhotoOverlay(objectSimpleExtensions, idAttributes, name, visibility, open, author, link, address, addressDetails, phoneNumber, snippet, description, view, timePrimitive, styleUrl, styleSelector, region, extendedData, abstractOverlaySimpleExtensions, abstractOverlayObjectExtensions, color, drawOrder, icon, abstractOverlaySimpleExtensions, abstractOverlayObjectExtensions, rotation, viewVolume, imagePyramid, point, shape, photoOverlaySimpleExtensions, photoOverlayObjectExtensions);
}
Also used : Shape(org.geotoolkit.data.kml.model.Shape) AbstractTimePrimitive(org.geotoolkit.data.kml.model.AbstractTimePrimitive) AtomLink(org.geotoolkit.atom.model.AtomLink) ArrayList(java.util.ArrayList) ImagePyramid(org.geotoolkit.data.kml.model.ImagePyramid) 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) IdAttributes(org.geotoolkit.data.kml.model.IdAttributes) AtomPersonConstruct(org.geotoolkit.atom.model.AtomPersonConstruct) Entry(java.util.Map.Entry) ViewVolume(org.geotoolkit.data.kml.model.ViewVolume) AbstractView(org.geotoolkit.data.kml.model.AbstractView) AddressDetails(org.geotoolkit.xal.model.AddressDetails) Color(java.awt.Color) Point(org.geotoolkit.data.kml.model.Point) 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 10 with AddressDetails

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

the class GxReader method readTour.

/**
 * @return
 * @throws XMLStreamException
 * @throws KmlException
 * @throws URISyntaxException
 */
public Feature readTour() throws XMLStreamException, KmlException, URISyntaxException {
    // AbstractObject
    List<SimpleTypeContainer> objectSimpleExtensions = null;
    IdAttributes idAttributes = kmlReader.readIdAttributes();
    // AbstractFeature
    String name = null;
    boolean visibility = KmlConstants.DEF_VISIBILITY;
    boolean open = KmlConstants.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 = null;
    List<AbstractObject> featureObjectExtensions = null;
    // Tour
    List<PlayList> playlists = new ArrayList<PlayList>();
    boucle: while (reader.hasNext()) {
        switch(reader.next()) {
            case XMLStreamConstants.START_ELEMENT:
                final String eName = reader.getLocalName();
                final String eUri = reader.getNamespaceURI();
                if (this.kmlReader.getVersionUri().equals(eUri)) {
                    // ABSTRACT FEATURE
                    if (KmlConstants.TAG_NAME.equals(eName)) {
                        name = reader.getElementText();
                    } else if (KmlConstants.TAG_VISIBILITY.equals(eName)) {
                        visibility = parseBoolean(reader.getElementText());
                    } else if (KmlConstants.TAG_OPEN.equals(eName)) {
                        open = parseBoolean(reader.getElementText());
                    } else if (KmlConstants.TAG_ADDRESS.equals(eName)) {
                        address = reader.getElementText();
                    } else if (KmlConstants.TAG_PHONE_NUMBER.equals(eName)) {
                        phoneNumber = reader.getElementText();
                    } else if (KmlConstants.TAG_SNIPPET.equals(eName)) {
                        snippet = kmlReader.readElementText();
                    } else if (KmlConstants.TAG_SNIPPET_BIG.equals(eName)) {
                        snippet = kmlReader.readSnippet();
                    } else if (KmlConstants.TAG_DESCRIPTION.equals(eName)) {
                        description = kmlReader.readElementText();
                    } else if (isAbstractView(eName)) {
                        view = kmlReader.readAbstractView(eName);
                    } else if (isAbstractTimePrimitive(eName)) {
                        timePrimitive = kmlReader.readAbstractTimePrimitive(eName);
                    } else if (KmlConstants.TAG_STYLE_URL.equals(eName)) {
                        styleUrl = new URI(reader.getElementText());
                    } else if (isAbstractStyleSelector(eName)) {
                        styleSelector.add(kmlReader.readAbstractStyleSelector(eName));
                    } else if (KmlConstants.TAG_REGION.equals(eName)) {
                        region = kmlReader.readRegion();
                    } else if (KmlConstants.TAG_EXTENDED_DATA.equals(eName)) {
                        extendedData = kmlReader.readExtendedData();
                    } else if (KmlConstants.TAG_META_DATA.equals(eName)) {
                        extendedData = kmlReader.readMetaData();
                    }
                } else if (KmlConstants.URI_ATOM.equals(eUri)) {
                    kmlReader.checkVersion(URI_KML_2_2);
                    // ABSTRACT FEATURE
                    if (KmlConstants.TAG_ATOM_AUTHOR.equals(eName)) {
                        author = kmlReader.readAtomPersonConstruct();
                    } else if (KmlConstants.TAG_ATOM_LINK.equals(eName)) {
                        link = kmlReader.readAtomLink();
                    }
                } else if (KmlConstants.URI_XAL.equals(eUri)) {
                    kmlReader.checkVersion(URI_KML_2_2);
                    // ABSTRACT FEATURE
                    if (KmlConstants.TAG_XAL_ADDRESS_DETAILS.equals(eName)) {
                        addressDetails = kmlReader.readXalAddressDetails();
                    }
                } else if (URI_GX.equals(eUri)) {
                    if (TAG_PLAYLIST.equals(eName)) {
                        playlists.add(this.readPlayList());
                    }
                }
                break;
            case XMLStreamConstants.END_ELEMENT:
                if (TAG_TOUR.equals(reader.getLocalName()) && URI_GX.contains(reader.getNamespaceURI())) {
                    break boucle;
                }
                break;
        }
    }
    return GxReader.GX_FACTORY.createTour(objectSimpleExtensions, idAttributes, name, visibility, open, author, link, address, addressDetails, phoneNumber, snippet, description, view, timePrimitive, styleUrl, styleSelector, region, extendedData, featureSimpleExtensions, featureObjectExtensions, playlists);
}
Also used : PlayList(org.geotoolkit.data.gx.model.PlayList) 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) SimpleTypeContainer(org.geotoolkit.data.kml.xsd.SimpleTypeContainer) URI(java.net.URI) AbstractStyleSelector(org.geotoolkit.data.kml.model.AbstractStyleSelector) IdAttributes(org.geotoolkit.data.kml.model.IdAttributes) AtomPersonConstruct(org.geotoolkit.atom.model.AtomPersonConstruct) AbstractObject(org.geotoolkit.data.kml.model.AbstractObject) Region(org.geotoolkit.data.kml.model.Region) AbstractObject(org.geotoolkit.data.kml.model.AbstractObject)

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