Search in sources :

Example 6 with AtomLink

use of org.geotoolkit.atom.model.AtomLink in project geotoolkit by Geomatys.

the class AtomLinkTest method atomLinkWriteTest.

@Test
public void atomLinkWriteTest() throws XMLStreamException, IOException, ParserConfigurationException, SAXException {
    final AtomFactory atomFactory = DefaultAtomFactory.getInstance();
    final AtomLink link = atomFactory.createAtomLink();
    link.setHref("HREF");
    link.setRel("REL");
    link.setType("TYPE/TYPE");
    link.setHreflang("HREFLANG-hqls5");
    link.setTitle("TITLE");
    link.setLength("LENGTH");
    File temp = File.createTempFile("link", ".atom");
    temp.deleteOnExit();
    AtomWriter writer = new AtomWriter();
    writer.setOutput(temp);
    writer.getWriter().writeStartDocument("UTF-8", "1.0");
    writer.getWriter().setDefaultNamespace(AtomConstants.URI_ATOM);
    writer.writeLink(link);
    writer.getWriter().writeEndDocument();
    writer.getWriter().flush();
    writer.dispose();
    DomCompare.compare(new File(pathToTestFile), temp);
}
Also used : AtomLink(org.geotoolkit.atom.model.AtomLink) AtomWriter(org.geotoolkit.atom.xml.AtomWriter) File(java.io.File) Test(org.junit.Test)

Example 7 with AtomLink

use of org.geotoolkit.atom.model.AtomLink 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 AtomLink

use of org.geotoolkit.atom.model.AtomLink 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 AtomLink

use of org.geotoolkit.atom.model.AtomLink 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 AtomLink

use of org.geotoolkit.atom.model.AtomLink 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

AtomLink (org.geotoolkit.atom.model.AtomLink)10 URI (java.net.URI)8 ArrayList (java.util.ArrayList)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 AddressDetails (org.geotoolkit.xal.model.AddressDetails)8 Entry (java.util.Map.Entry)7 Extensions (org.geotoolkit.data.kml.model.Extensions)7 LineString (org.geotoolkit.data.kml.model.LineString)7 Color (java.awt.Color)3 Icon (org.geotoolkit.data.kml.model.Icon)3 ItemIcon (org.geotoolkit.data.kml.model.ItemIcon)3 Point (org.geotoolkit.data.kml.model.Point)3 File (java.io.File)2 Test (org.junit.Test)2