use of org.geotoolkit.data.kml.model.AltitudeMode in project geotoolkit by Geomatys.
the class KmlReader method readCamera.
private Camera readCamera() throws XMLStreamException, KmlException, URISyntaxException {
// AbstractObject
List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
IdAttributes idAttributes = readIdAttributes();
// AbstractView
List<SimpleTypeContainer> abstractViewSimpleExtensions = new ArrayList<>();
List<Object> abstractViewObjectExtensions = new ArrayList<>();
// Camera
double longitude = DEF_LONGITUDE;
double latitude = DEF_LATITUDE;
double altitude = DEF_ALTITUDE;
double heading = DEF_HEADING;
double tilt = DEF_TILT;
double roll = DEF_ROLL;
AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
List<SimpleTypeContainer> cameraSimpleExtensions = new ArrayList<>();
List<Object> cameraObjectExtensions = 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_LONGITUDE:
longitude = parseDouble(reader.getElementText());
break;
case TAG_LATITUDE:
latitude = parseDouble(reader.getElementText());
break;
case TAG_ALTITUDE:
altitude = parseDouble(reader.getElementText());
break;
case TAG_HEADING:
heading = parseDouble(reader.getElementText());
break;
case TAG_TILT:
tilt = parseDouble(reader.getElementText());
break;
case TAG_ROLL:
roll = parseDouble(reader.getElementText());
break;
case TAG_ALTITUDE_MODE:
altitudeMode = readAltitudeMode();
break;
}
} else // EXTENSIONS
{
KmlExtensionReader r;
if ((r = this.getComplexExtensionReader(TAG_CAMERA, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_CAMERA, eUri, eName);
Object ext = result.getKey();
Extensions.Names extensionLevel = result.getValue();
if (Extensions.Names.VIEW.equals(extensionLevel)) {
abstractViewObjectExtensions.add(ext);
} else if (Extensions.Names.CAMERA.equals(extensionLevel)) {
cameraObjectExtensions.add(ext);
} else if (extensionLevel == null) {
if (ext instanceof AltitudeMode) {
altitudeMode = (AltitudeMode) ext;
}
}
} else if ((r = getSimpleExtensionReader(TAG_CAMERA, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_CAMERA, 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.VIEW.equals(extensionLevel)) {
abstractViewSimpleExtensions.add((SimpleTypeContainer) ext);
} else if (Extensions.Names.CAMERA.equals(extensionLevel)) {
cameraSimpleExtensions.add((SimpleTypeContainer) ext);
}
}
}
break;
}
case XMLStreamConstants.END_ELEMENT:
{
if (TAG_CAMERA.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
break boucle;
}
break;
}
}
}
return KmlReader.KML_FACTORY.createCamera(objectSimpleExtensions, idAttributes, abstractViewSimpleExtensions, abstractViewObjectExtensions, longitude, latitude, altitude, heading, tilt, roll, altitudeMode, cameraSimpleExtensions, cameraObjectExtensions);
}
use of org.geotoolkit.data.kml.model.AltitudeMode in project geotoolkit by Geomatys.
the class KmlReader method readModel.
public Model readModel() throws XMLStreamException, KmlException, URISyntaxException {
// AbstractObject
List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
IdAttributes idAttributes = readIdAttributes();
// AbstractGeometry
List<SimpleTypeContainer> abstractGeometrySimpleExtensions = new ArrayList<>();
List<Object> abstractGeometryObjectExtensions = new ArrayList<>();
// Model
AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
Location location = null;
Orientation orientation = null;
Scale scale = null;
Link link = null;
ResourceMap resourceMap = null;
List<SimpleTypeContainer> modelSimpleExtensions = new ArrayList<>();
List<Object> modelObjectExtensions = 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_ALTITUDE_MODE:
altitudeMode = readAltitudeMode();
break;
case TAG_LOCATION:
location = readLocation();
break;
case TAG_ORIENTATION:
orientation = readOrientation();
break;
case TAG_SCALE_BIG:
scale = readScale();
break;
case TAG_LINK:
link = readLink(eName);
break;
case TAG_RESOURCE_MAP:
checkVersion(URI_KML_2_2);
resourceMap = readResourceMap();
break;
}
} else // EXTENSIONS
{
KmlExtensionReader r;
if ((r = this.getComplexExtensionReader(TAG_MODEL, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_MODEL, eUri, eName);
Object ext = result.getKey();
Extensions.Names extensionLevel = result.getValue();
if (Extensions.Names.GEOMETRY.equals(extensionLevel)) {
abstractGeometryObjectExtensions.add(ext);
} else if (Extensions.Names.MODEL.equals(extensionLevel)) {
modelObjectExtensions.add(ext);
} else if (extensionLevel == null) {
if (ext instanceof AltitudeMode) {
altitudeMode = (AltitudeMode) ext;
}
}
} else if ((r = getSimpleExtensionReader(TAG_MODEL, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_MODEL, 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.MODEL.equals(extensionLevel)) {
modelSimpleExtensions.add((SimpleTypeContainer) ext);
}
}
}
break;
}
case XMLStreamConstants.END_ELEMENT:
{
if (TAG_MODEL.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
break boucle;
}
break;
}
}
}
return KmlReader.KML_FACTORY.createModel(objectSimpleExtensions, idAttributes, abstractGeometrySimpleExtensions, abstractGeometryObjectExtensions, altitudeMode, location, orientation, scale, link, resourceMap, modelSimpleExtensions, modelObjectExtensions);
}
use of org.geotoolkit.data.kml.model.AltitudeMode in project geotoolkit by Geomatys.
the class KmlReader method readPolygon.
private Polygon readPolygon() throws XMLStreamException, KmlException, URISyntaxException {
// AbstractObject
List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
IdAttributes idAttributes = readIdAttributes();
// AbstractGeometry
List<SimpleTypeContainer> abstractGeometrySimpleExtensions = new ArrayList<>();
List<Object> abstractGeometryObjectExtensions = new ArrayList<>();
// Polygon
boolean extrude = DEF_EXTRUDE;
boolean tessellate = DEF_TESSELLATE;
AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
Boundary outerBoundaryIs = null;
List<Boundary> innerBoundariesAre = new ArrayList<>();
List<SimpleTypeContainer> polygonSimpleExtensions = new ArrayList<>();
List<Object> polygonObjectExtensions = 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)) {
if (eName != null)
switch(// POLYGON
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_OUTER_BOUNDARY_IS:
outerBoundaryIs = readBoundary();
break;
case TAG_INNER_BOUNDARY_IS:
innerBoundariesAre.add(readBoundary());
break;
}
} else // EXTENSIONS
{
KmlExtensionReader r;
if ((r = this.getComplexExtensionReader(TAG_POLYGON, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_POLYGON, eUri, eName);
Object ext = result.getKey();
Extensions.Names extensionLevel = result.getValue();
if (Extensions.Names.GEOMETRY.equals(extensionLevel)) {
abstractGeometryObjectExtensions.add(ext);
} else if (Extensions.Names.POLYGON.equals(extensionLevel)) {
polygonObjectExtensions.add(ext);
} else if (extensionLevel == null) {
if (ext instanceof AltitudeMode) {
altitudeMode = (AltitudeMode) ext;
}
}
} else if ((r = getSimpleExtensionReader(TAG_POLYGON, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_POLYGON, 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.POLYGON.equals(extensionLevel)) {
polygonSimpleExtensions.add((SimpleTypeContainer) ext);
}
}
}
break;
}
case XMLStreamConstants.END_ELEMENT:
{
if (TAG_POLYGON.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
break boucle;
}
break;
}
}
}
return KmlReader.KML_FACTORY.createPolygon(objectSimpleExtensions, idAttributes, abstractGeometrySimpleExtensions, abstractGeometryObjectExtensions, extrude, tessellate, altitudeMode, outerBoundaryIs, innerBoundariesAre, polygonSimpleExtensions, polygonObjectExtensions);
}
use of org.geotoolkit.data.kml.model.AltitudeMode in project geotoolkit by Geomatys.
the class KmlReader method readPoint.
private Point readPoint() throws XMLStreamException, KmlException, URISyntaxException {
// AbstractObject
List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
IdAttributes idAttributes = readIdAttributes();
// AbstractGeometry
List<SimpleTypeContainer> abstractGeometrySimpleExtensions = new ArrayList<>();
List<Object> abstractGeometryObjectExtensions = new ArrayList<>();
// Point
boolean extrude = DEF_EXTRUDE;
AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
CoordinateSequence coordinates = null;
List<SimpleTypeContainer> pointSimpleExtensions = new ArrayList<>();
List<Object> pointObjectExtensions = 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_EXTRUDE:
extrude = 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_POINT, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_POINT, eUri, eName);
Object ext = result.getKey();
Extensions.Names extensionLevel = result.getValue();
if (Extensions.Names.GEOMETRY.equals(extensionLevel)) {
abstractGeometryObjectExtensions.add(ext);
} else if (Extensions.Names.POINT.equals(extensionLevel)) {
pointObjectExtensions.add(ext);
} else if (extensionLevel == null) {
if (ext instanceof AltitudeMode) {
altitudeMode = (AltitudeMode) ext;
}
}
} else if ((r = getSimpleExtensionReader(TAG_POINT, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_POINT, 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.POINT.equals(extensionLevel)) {
pointSimpleExtensions.add((SimpleTypeContainer) ext);
}
}
}
break;
}
case XMLStreamConstants.END_ELEMENT:
{
if (TAG_POINT.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
break boucle;
}
break;
}
}
}
return KmlReader.KML_FACTORY.createPoint(objectSimpleExtensions, idAttributes, abstractGeometrySimpleExtensions, abstractGeometryObjectExtensions, extrude, altitudeMode, coordinates, pointSimpleExtensions, pointObjectExtensions);
}
use of org.geotoolkit.data.kml.model.AltitudeMode in project geotoolkit by Geomatys.
the class KmlReader method readLookAt.
private LookAt readLookAt() throws XMLStreamException, KmlException, URISyntaxException {
// AbstractObject
List<SimpleTypeContainer> objectSimpleExtensions = new ArrayList<>();
IdAttributes idAttributes = readIdAttributes();
// AbstractView
List<SimpleTypeContainer> abstractViewSimpleExtensions = new ArrayList<>();
List<Object> abstractViewObjectExtensions = new ArrayList<>();
// LookAt
double longitude = DEF_LONGITUDE;
double latitude = DEF_LATITUDE;
double altitude = DEF_ALTITUDE;
double heading = DEF_HEADING;
double tilt = DEF_TILT;
double range = DEF_RANGE;
AltitudeMode altitudeMode = DEF_ALTITUDE_MODE;
List<SimpleTypeContainer> lookAtSimpleExtensions = new ArrayList<>();
List<Object> lookAtObjectExtensions = 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_LONGITUDE:
longitude = parseDouble(reader.getElementText());
break;
case TAG_LATITUDE:
latitude = parseDouble(reader.getElementText());
break;
case TAG_ALTITUDE:
altitude = parseDouble(reader.getElementText());
break;
case TAG_HEADING:
heading = parseDouble(reader.getElementText());
break;
case TAG_TILT:
if (checkVersionSimple(URI_KML_2_1)) {
tilt = KmlUtilities.checkAnglePos90(parseDouble(reader.getElementText()));
} else {
tilt = parseDouble(reader.getElementText());
}
break;
case TAG_RANGE:
range = parseDouble(reader.getElementText());
break;
case TAG_ALTITUDE_MODE:
altitudeMode = readAltitudeMode();
break;
}
} else // EXTENSIONS
{
KmlExtensionReader r;
if ((r = this.getComplexExtensionReader(TAG_LOOK_AT, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_LOOK_AT, eUri, eName);
Object ext = result.getKey();
Extensions.Names extensionLevel = result.getValue();
if (Extensions.Names.VIEW.equals(extensionLevel)) {
abstractViewObjectExtensions.add(ext);
} else if (Extensions.Names.LOOK_AT.equals(extensionLevel)) {
lookAtObjectExtensions.add(ext);
} else if (extensionLevel == null) {
if (ext instanceof AltitudeMode) {
altitudeMode = (AltitudeMode) ext;
}
}
} else if ((r = getSimpleExtensionReader(TAG_LOOK_AT, eUri, eName)) != null) {
Entry<Object, Extensions.Names> result = r.readExtensionElement(URI_KML, TAG_LOOK_AT, 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.VIEW.equals(extensionLevel)) {
abstractViewSimpleExtensions.add((SimpleTypeContainer) ext);
} else if (Extensions.Names.LOOK_AT.equals(extensionLevel)) {
lookAtSimpleExtensions.add((SimpleTypeContainer) ext);
}
}
}
break;
}
case XMLStreamConstants.END_ELEMENT:
{
if (TAG_LOOK_AT.equals(reader.getLocalName()) && containsNamespace(reader.getNamespaceURI())) {
break boucle;
}
break;
}
}
}
return KmlReader.KML_FACTORY.createLookAt(objectSimpleExtensions, idAttributes, abstractViewSimpleExtensions, abstractViewObjectExtensions, longitude, latitude, altitude, heading, tilt, range, altitudeMode, lookAtSimpleExtensions, lookAtObjectExtensions);
}
Aggregations