Skip to content

Commit

Permalink
feat(cesium-test-app): Add KML source example
Browse files Browse the repository at this point in the history
  • Loading branch information
jmacura committed Mar 22, 2024
1 parent 8a772ca commit 470df77
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
16 changes: 13 additions & 3 deletions projects/cesium-test-app/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
HeadingPitchRoll,
Transforms,
} from 'cesium';
import {GeoJSON} from 'ol/format';
import {GeoJSON, KML} from 'ol/format';
import {Image as ImageLayer, Tile, Vector as VectorLayer} from 'ol/layer';
import {OSM, Vector as VectorSource, XYZ} from 'ol/source';
import {View} from 'ol';
Expand Down Expand Up @@ -44,6 +44,15 @@ export class AppComponent implements OnInit {
format: new GeoJSON(),
}) as VectorSource, //FIXME: Type-cast shall be automatically inferred after OL >8.2
});
const polygon25dKml = new VectorLayer({
properties: {
title: '2.5D polygon surface as KML',
},
source: new VectorSource({
url: '../assets/polygon2.5d.kml',
format: new KML(),
}) as VectorSource, //FIXME: Type-cast shall be automatically inferred after OL >8.2
});
const geojsonObject2d = {
'type': 'FeatureCollection',
'crs': {
Expand Down Expand Up @@ -203,8 +212,8 @@ export class AppComponent implements OnInit {
],
popUpDisplay: 'hover',
default_view: new View({
center: transform([17.474129, 52.574], 'EPSG:4326', 'EPSG:3857'), //Latitude longitude to Spherical Mercator
zoom: 4,
center: transform([13.3, 49.7], 'EPSG:4326', 'EPSG:3857'), //Latitude longitude to Spherical Mercator
zoom: 12,
}),
default_layers: [
new Tile({
Expand Down Expand Up @@ -263,6 +272,7 @@ export class AppComponent implements OnInit {
}) as VectorSource, //FIXME: Type-cast shall be automatically inferred after OL >8.2
}),
polygon25d,
polygon25dKml,
opticalMap,
],
});
Expand Down
17 changes: 17 additions & 0 deletions projects/cesium-test-app/src/assets/polygon2.5d.kml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8" ?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document id="root_doc">
<Schema name="polygon2.5d" id="polygon2.5d">
<SimpleField name="height" type="int"></SimpleField>
</Schema>
<Folder><name>polygon2.5d</name>
<Placemark>
<name>Polygon with height higher than its Z-coords</name>
<Style><LineStyle><color>ff0000ff</color></LineStyle><PolyStyle><fill>0</fill></PolyStyle></Style>
<ExtendedData><SchemaData schemaUrl="#polygon2.5d">
<SimpleData name="height">800</SimpleData>
</SchemaData></ExtendedData>
<Polygon><outerBoundaryIs><LinearRing><coordinates>13.365,49.74,350 13.363,49.735,400 13.37,49.735,450 13.373,49.74,500 13.372,49.74,650 13.368,49.738,700 13.365,49.74,350</coordinates></LinearRing></outerBoundaryIs></Polygon>
</Placemark>
</Folder>
</Document></kml>

0 comments on commit 470df77

Please sign in to comment.