Search in sources :

Example 1 with ImagePyramid

use of org.geotoolkit.data.kml.model.ImagePyramid 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)

Aggregations

Color (java.awt.Color)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 AtomLink (org.geotoolkit.atom.model.AtomLink)1 AtomPersonConstruct (org.geotoolkit.atom.model.AtomPersonConstruct)1 AbstractStyleSelector (org.geotoolkit.data.kml.model.AbstractStyleSelector)1 AbstractTimePrimitive (org.geotoolkit.data.kml.model.AbstractTimePrimitive)1 AbstractView (org.geotoolkit.data.kml.model.AbstractView)1 Extensions (org.geotoolkit.data.kml.model.Extensions)1 Icon (org.geotoolkit.data.kml.model.Icon)1 IdAttributes (org.geotoolkit.data.kml.model.IdAttributes)1 ImagePyramid (org.geotoolkit.data.kml.model.ImagePyramid)1 ItemIcon (org.geotoolkit.data.kml.model.ItemIcon)1 LineString (org.geotoolkit.data.kml.model.LineString)1 Point (org.geotoolkit.data.kml.model.Point)1 Region (org.geotoolkit.data.kml.model.Region)1 Shape (org.geotoolkit.data.kml.model.Shape)1 ViewVolume (org.geotoolkit.data.kml.model.ViewVolume)1 SimpleTypeContainer (org.geotoolkit.data.kml.xsd.SimpleTypeContainer)1