use of org.geotoolkit.data.kml.model.AltitudeMode in project geotoolkit by Geomatys.
the class GxReader method readTrack.
/**
* @return
* @throws XMLStreamException
* @throws KmlException
* @throws URISyntaxException
*/
public Track readTrack() throws XMLStreamException, KmlException, URISyntaxException {
AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
List<Calendar> whens = new ArrayList<Calendar>();
List<Coordinate> coordinates = new ArrayList<Coordinate>();
List<Angles> anglesList = new ArrayList<Angles>();
Model model = null;
ExtendedData extendedData = null;
boucle: while (reader.hasNext()) {
switch(reader.next()) {
case XMLStreamConstants.START_ELEMENT:
final String eName = reader.getLocalName();
final String eUri = reader.getNamespaceURI();
if (URI_GX.equals(eUri)) {
if (TAG_ALTITUDE_MODE.equals(eName)) {
altitudeMode = this.readAltitudeMode();
} else if (TAG_COORD.equals(eName)) {
coordinates.add(this.readCoord());
} else if (TAG_ANGLES.equals(eName)) {
anglesList.add(this.readAngles());
}
} else if (this.kmlReader.getVersionUri().equals(eUri)) {
if (KmlConstants.TAG_ALTITUDE_MODE.equals(eName)) {
altitudeMode = kmlReader.readAltitudeMode();
} else if (KmlConstants.TAG_WHEN.equals(eName)) {
whens.add(kmlReader.readCalendar());
} else if (KmlConstants.TAG_MODEL.equals(eName)) {
model = kmlReader.readModel();
} else if (KmlConstants.TAG_EXTENDED_DATA.equals(eName)) {
extendedData = kmlReader.readExtendedData();
}
}
break;
case XMLStreamConstants.END_ELEMENT:
if (TAG_TRACK.equals(reader.getLocalName()) && URI_GX.contains(reader.getNamespaceURI())) {
break boucle;
}
break;
}
}
CoordinateSequence coord = KML_FACTORY.createCoordinates(coordinates);
return GX_FACTORY.createTrack(altitudeMode, whens, coord, anglesList, model, extendedData);
}
use of org.geotoolkit.data.kml.model.AltitudeMode in project geotoolkit by Geomatys.
the class KmlReader method readLinearRing.
private LinearRing readLinearRing() throws XMLStreamException, KmlException, URISyntaxException {
// AbstractObject
List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
IdAttributes idAttributes = readIdAttributes();
// AbstractGeometry
List<SimpleTypeContainer> abstractGeometrySimpleExtensions = new ArrayList<>();
List<Object> abstractGeometryObjectExtensions = new ArrayList<>();
// LinearRing
boolean extrude = DEF_EXTRUDE;
boolean tessellate = DEF_TESSELLATE;
AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
CoordinateSequence coordinates = null;
List<SimpleTypeContainer> linearRingSimpleExtensions = new ArrayList<>();
List<Object> linearRingObjectExtensions = new ArrayList<>();
boucle: while (reader.hasNext()) {
switch(reader.next()) {
case XMLStreamConstants.START_ELEMENT:
{
final String eName = reader.getLocalName();
final String eUri = reader.getNamespaceURI();
// LINEAR RING
if (equalsNamespace(eUri)) {
switch(eName) {
case TAG_EXTRUDE:
extrude = parseBoolean(reader.getElementText());
break;
case TAG_TESSELLATE:
tessellate = parseBoolean(reader.getElementText());
break;
case TAG_ALTITUDE_MODE:
altitudeMode = readAltitudeMode();
break;
case TAG_COORDINATES:
coordinates = readCoordinates(reader.getElementText());
break;
}
} else // EXTENSIONS
{
KmlExtensionReader r;
if ((r = this.getComplexExtensionReader(TAG_LINEAR_RING, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_LINEAR_RING, eUri, eName);
Object ext = result.getKey();
Extensions.Names extensionLevel = result.getValue();
if (Extensions.Names.GEOMETRY.equals(extensionLevel)) {
abstractGeometryObjectExtensions.add(ext);
} else if (Extensions.Names.LINEAR_RING.equals(extensionLevel)) {
linearRingObjectExtensions.add(ext);
} else if (extensionLevel == null) {
if (ext instanceof AltitudeMode) {
altitudeMode = (AltitudeMode) ext;
}
}
} else if ((r = getSimpleExtensionReader(TAG_LINEAR_RING, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_LINEAR_RING, 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.GEOMETRY.equals(extensionLevel)) {
abstractGeometrySimpleExtensions.add((SimpleTypeContainer) ext);
} else if (Extensions.Names.LINEAR_RING.equals(extensionLevel)) {
linearRingSimpleExtensions.add((SimpleTypeContainer) ext);
}
}
}
break;
}
case XMLStreamConstants.END_ELEMENT:
{
if (TAG_LINEAR_RING.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
break boucle;
}
break;
}
}
}
return KmlReader.KML_FACTORY.createLinearRing(objectSimpleExtensions, idAttributes, abstractGeometrySimpleExtensions, abstractGeometryObjectExtensions, extrude, tessellate, altitudeMode, coordinates, linearRingSimpleExtensions, linearRingObjectExtensions);
}
use of org.geotoolkit.data.kml.model.AltitudeMode in project geotoolkit by Geomatys.
the class KmlReader method readLineString.
private LineString readLineString() throws XMLStreamException, KmlException, URISyntaxException {
// AbstractObject
List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
IdAttributes idAttributes = readIdAttributes();
// AbstractGeometry
List<SimpleTypeContainer> abstractGeometrySimpleExtensions = new ArrayList<>();
List<Object> abstractGeometryObjectExtensions = new ArrayList<>();
// LineString
boolean extrude = DEF_EXTRUDE;
boolean tessellate = DEF_TESSELLATE;
AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
CoordinateSequence coordinates = null;
List<SimpleTypeContainer> lineStringSimpleExtensions = new ArrayList<>();
List<Object> lineStringObjectExtensions = new ArrayList<>();
boucle: while (reader.hasNext()) {
switch(reader.next()) {
case XMLStreamConstants.START_ELEMENT:
{
final String eName = reader.getLocalName();
final String eUri = reader.getNamespaceURI();
// LINE STRING
if (equalsNamespace(eUri)) {
switch(eName) {
case TAG_EXTRUDE:
extrude = parseBoolean(reader.getElementText());
break;
case TAG_TESSELLATE:
tessellate = parseBoolean(reader.getElementText());
break;
case TAG_ALTITUDE_MODE:
altitudeMode = readAltitudeMode();
break;
case TAG_COORDINATES:
coordinates = readCoordinates(reader.getElementText());
break;
}
} else // EXTENSIONS
{
KmlExtensionReader r;
if ((r = this.getComplexExtensionReader(TAG_LINE_STRING, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_LINE_STRING, eUri, eName);
Object ext = result.getKey();
Extensions.Names extensionLevel = result.getValue();
if (Extensions.Names.GEOMETRY.equals(extensionLevel)) {
abstractGeometryObjectExtensions.add(ext);
} else if (Extensions.Names.LINE_STRING.equals(extensionLevel)) {
lineStringObjectExtensions.add(ext);
} else if (extensionLevel == null) {
if (ext instanceof AltitudeMode) {
altitudeMode = (AltitudeMode) ext;
}
}
} else if ((r = getSimpleExtensionReader(TAG_LINE_STRING, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_LINE_STRING, 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.GEOMETRY.equals(extensionLevel)) {
abstractGeometrySimpleExtensions.add((SimpleTypeContainer) ext);
} else if (Extensions.Names.LINE_STRING.equals(extensionLevel)) {
lineStringSimpleExtensions.add((SimpleTypeContainer) ext);
}
}
}
break;
}
case XMLStreamConstants.END_ELEMENT:
{
if (TAG_LINE_STRING.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
break boucle;
}
break;
}
}
}
return KmlReader.KML_FACTORY.createLineString(objectSimpleExtensions, idAttributes, abstractGeometrySimpleExtensions, abstractGeometryObjectExtensions, extrude, tessellate, altitudeMode, coordinates, lineStringSimpleExtensions, lineStringObjectExtensions);
}
use of org.geotoolkit.data.kml.model.AltitudeMode in project geotoolkit by Geomatys.
the class KmlReader method readGroundOverlay.
private Feature readGroundOverlay() throws XMLStreamException, KmlException, URISyntaxException {
// AbstractObject
List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
IdAttributes idAttributes = readIdAttributes();
// AbstractFeature
String name = null;
boolean visibility = DEF_VISIBILITY;
boolean open = DEF_OPEN;
AtomPersonConstruct author = null;
AtomLink link = null;
String address = null;
AddressDetails addressDetails = null;
String phoneNumber = null;
Object snippet = null;
Object description = null;
AbstractView view = null;
AbstractTimePrimitive timePrimitive = null;
URI styleUrl = null;
List<AbstractStyleSelector> styleSelector = new ArrayList<>();
Region region = null;
Object extendedData = null;
List<SimpleTypeContainer> featureSimpleExtensions = new ArrayList<>();
List<Object> featureObjectExtensions = new ArrayList<>();
// AbstractOverlay
Color color = DEF_COLOR;
int drawOrder = DEF_DRAW_ORDER;
Icon icon = null;
List<SimpleTypeContainer> abstractOverlaySimpleExtensions = new ArrayList<>();
List<Object> abstractOverlayObjectExtensions = new ArrayList<>();
// GroundOverlay
double altitude = DEF_ALTITUDE;
AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
LatLonBox latLonBox = null;
List<SimpleTypeContainer> groundOverlaySimpleExtensions = new ArrayList<>();
List<Object> groundOverlayObjectExtensions = new ArrayList<>();
boucle: while (reader.hasNext()) {
switch(reader.next()) {
case XMLStreamConstants.START_ELEMENT:
{
final String eName = reader.getLocalName();
final String eUri = reader.getNamespaceURI();
// KML
if (equalsNamespace(eUri)) {
switch(eName) {
case TAG_NAME:
name = reader.getElementText();
break;
case TAG_VISIBILITY:
visibility = parseBoolean(reader.getElementText());
break;
case TAG_OPEN:
open = parseBoolean(reader.getElementText());
break;
case TAG_ADDRESS:
address = reader.getElementText();
break;
case TAG_PHONE_NUMBER:
phoneNumber = reader.getElementText();
break;
case TAG_SNIPPET:
snippet = readElementText();
break;
case TAG_SNIPPET_BIG:
snippet = readSnippet();
break;
case TAG_DESCRIPTION:
description = readElementText();
break;
case TAG_STYLE_URL:
styleUrl = new URI(reader.getElementText());
break;
case TAG_REGION:
region = readRegion();
break;
case TAG_EXTENDED_DATA:
extendedData = readExtendedData();
break;
case TAG_META_DATA:
extendedData = readMetaData();
break;
case TAG_COLOR:
color = KmlUtilities.parseColor(reader.getElementText());
break;
case TAG_DRAW_ORDER:
drawOrder = Integer.parseInt(reader.getElementText());
break;
case TAG_ICON:
icon = readIcon(eName);
break;
case TAG_ALTITUDE:
altitude = parseDouble(reader.getElementText());
break;
case TAG_ALTITUDE_MODE:
altitudeMode = readAltitudeMode();
break;
case TAG_LAT_LON_BOX:
latLonBox = readLatLonBox();
break;
default:
{
if (isAbstractView(eName)) {
view = readAbstractView(eName);
} else if (isAbstractTimePrimitive(eName)) {
timePrimitive = readAbstractTimePrimitive(eName);
} else if (isAbstractStyleSelector(eName)) {
styleSelector.add(readAbstractStyleSelector(eName));
}
break;
}
}
} else if (URI_ATOM.equals(eUri)) {
checkVersion(URI_KML_2_2);
// ABSTRACT FEATURE
if (TAG_ATOM_AUTHOR.equals(eName)) {
author = readAtomPersonConstruct();
} else if (TAG_ATOM_LINK.equals(eName)) {
link = readAtomLink();
}
} else if (URI_XAL.equals(eUri)) {
checkVersion(URI_KML_2_2);
// ABSTRACT FEATURE
if (TAG_XAL_ADDRESS_DETAILS.equals(eName)) {
addressDetails = readXalAddressDetails();
}
} else // EXTENSIONS
{
KmlExtensionReader r;
if ((r = this.getComplexExtensionReader(TAG_GROUND_OVERLAY, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_GROUND_OVERLAY, eUri, eName);
Object ext = result.getKey();
Extensions.Names extensionLevel = result.getValue();
if (Extensions.Names.FEATURE.equals(extensionLevel)) {
featureObjectExtensions.add(ext);
} else if (Extensions.Names.OVERLAY.equals(extensionLevel)) {
abstractOverlayObjectExtensions.add(ext);
} else if (Extensions.Names.GROUND_OVERLAY.equals(extensionLevel)) {
groundOverlayObjectExtensions.add(ext);
} else if (extensionLevel == null) {
if (ext instanceof AltitudeMode) {
altitudeMode = (AltitudeMode) ext;
}
}
} else if ((r = getSimpleExtensionReader(TAG_GROUND_OVERLAY, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_GROUND_OVERLAY, eUri, eName);
Object ext = result.getKey();
Extensions.Names extensionLevel = result.getValue();
if (Extensions.Names.OBJECT.equals(extensionLevel)) {
objectSimpleExtensions.add((SimpleTypeContainer) ext);
} else if (Extensions.Names.FEATURE.equals(extensionLevel)) {
featureSimpleExtensions.add((SimpleTypeContainer) ext);
} else if (Extensions.Names.OVERLAY.equals(extensionLevel)) {
abstractOverlaySimpleExtensions.add((SimpleTypeContainer) ext);
} else if (Extensions.Names.GROUND_OVERLAY.equals(extensionLevel)) {
groundOverlaySimpleExtensions.add((SimpleTypeContainer) ext);
}
}
}
break;
}
case XMLStreamConstants.END_ELEMENT:
{
if (TAG_GROUND_OVERLAY.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
break boucle;
}
break;
}
}
}
return KmlReader.KML_FACTORY.createGroundOverlay(objectSimpleExtensions, idAttributes, name, visibility, open, author, link, address, addressDetails, phoneNumber, snippet, description, view, timePrimitive, styleUrl, styleSelector, region, extendedData, featureSimpleExtensions, featureObjectExtensions, color, drawOrder, icon, abstractOverlaySimpleExtensions, abstractOverlayObjectExtensions, altitude, altitudeMode, latLonBox, groundOverlaySimpleExtensions, groundOverlayObjectExtensions);
}
use of org.geotoolkit.data.kml.model.AltitudeMode in project geotoolkit by Geomatys.
the class KmlReader method readLatLonAltBox.
private LatLonAltBox readLatLonAltBox() throws XMLStreamException, KmlException, URISyntaxException {
// AbstractObject
List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
IdAttributes idAttributes = readIdAttributes();
// AbstractLatLonBox
double north = DEF_NORTH;
double south = DEF_SOUTH;
double east = DEF_EAST;
double west = DEF_WEST;
List<SimpleTypeContainer> abstractLatLonBoxSimpleExtensions = new ArrayList<>();
List<Object> abstractLatLonBoxObjectExtensions = new ArrayList<>();
// LatLonAltBox
double minAltitude = DEF_MIN_ALTITUDE;
double maxAltitude = DEF_MAX_ALTITUDE;
AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
List<SimpleTypeContainer> latLonAltBoxSimpleExtensions = new ArrayList<>();
List<Object> latLonAltBoxObjectExtensions = 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_NORTH:
north = parseDouble(reader.getElementText());
break;
case TAG_SOUTH:
south = parseDouble(reader.getElementText());
break;
case TAG_EAST:
east = parseDouble(reader.getElementText());
break;
case TAG_WEST:
west = parseDouble(reader.getElementText());
break;
case TAG_MIN_ALTITUDE:
minAltitude = parseDouble(reader.getElementText());
break;
case TAG_MAX_ALTITUDE:
maxAltitude = parseDouble(reader.getElementText());
break;
case TAG_ALTITUDE_MODE:
altitudeMode = readAltitudeMode();
break;
}
} else // EXTENSIONS
{
KmlExtensionReader r;
if ((r = this.getComplexExtensionReader(TAG_LAT_LON_ALT_BOX, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_LAT_LON_ALT_BOX, eUri, eName);
Object ext = result.getKey();
Extensions.Names extensionLevel = result.getValue();
if (Extensions.Names.ABSTRACT_LAT_LON_BOX.equals(extensionLevel)) {
abstractLatLonBoxObjectExtensions.add(ext);
} else if (Extensions.Names.LAT_LON_ALT_BOX.equals(extensionLevel)) {
latLonAltBoxObjectExtensions.add(ext);
} else if (extensionLevel == null) {
if (ext instanceof AltitudeMode) {
altitudeMode = (AltitudeMode) ext;
}
}
} else if ((r = getSimpleExtensionReader(TAG_LAT_LON_ALT_BOX, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_LAT_LON_ALT_BOX, 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.ABSTRACT_LAT_LON_BOX.equals(extensionLevel)) {
abstractLatLonBoxSimpleExtensions.add((SimpleTypeContainer) ext);
} else if (Extensions.Names.LAT_LON_ALT_BOX.equals(extensionLevel)) {
latLonAltBoxSimpleExtensions.add((SimpleTypeContainer) ext);
}
}
}
break;
}
case XMLStreamConstants.END_ELEMENT:
{
if (TAG_LAT_LON_ALT_BOX.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
break boucle;
}
break;
}
}
}
return KmlReader.KML_FACTORY.createLatLonAltBox(objectSimpleExtensions, idAttributes, north, south, east, west, abstractLatLonBoxSimpleExtensions, abstractLatLonBoxObjectExtensions, minAltitude, maxAltitude, altitudeMode, latLonAltBoxSimpleExtensions, latLonAltBoxObjectExtensions);
}
Aggregations