GeoJsonPrimitive

Lightweight GeoJSON loader that converts features directly into BufferPointCollection, BufferPolylineCollection, and BufferPolygonCollection. Unlike GeoJsonDataSource, this path does not create entities. Instead, it exposes high-throughput buffer primitive collections that can be added directly to Scene#primitives.

new Ditap.GeoJsonPrimitive(options)

Name Type Description
options GeoJsonPrimitiveConstructorOptions optional
Examples:
// Load GeoJSON
const loader = await Ditap.GeoJsonPrimitive.fromUrl("./data.geojson");
viewer.scene.primitives.add(loader);
// Access GeoJSON features and properties
loader.points;     // BufferPointCollection | undefined
loader.polylines;  // BufferPolylineCollection | undefined
loader.polygons;   // BufferPolygonCollection | undefined
loader.ids;        // source feature IDs
loader.properties; // source feature properties
// Style GeoJSON
const material = new Ditap.BufferPolylineMaterial({
  color: Ditap.Color.RED,
  width: 4,
});

const polyline = new Ditap.BufferPolyline();
const count = primitive.polylines.primitiveCount;
for (let i = 0; i < count; i++) {
  primitive.polylines.get(i, polyline);

  const properties = primitive.getProperties(polyline.featureId);
  if (properties.myCustomProperty === true) {
    polyline.setMaterial(material);
  }
}
Experimental

This feature is not final and is subject to change without Cesium's standard deprecation policy.

Members

readonly featureCount : number

Feature count represented by the loaded collections.

readonly ids : Array.<(string|number|undefined)>

Lookup table from integer ID generated by GeoJsonPrimitive, to integer or string Feature ID from GeoJSON source.

readonly points : BufferPointCollection|undefined

Buffer point collection for point geometries.

readonly polygons : BufferPolygonCollection|undefined

Buffer polygon collection for polygon geometries.

readonly polylines : BufferPolylineCollection|undefined

Buffer polyline collection for linestring geometries.

readonly properties : Array.<Record.<string, unknown>>

Source GeoJSON properties, indexed by generated integer ID.

readonly url : string|undefined

Loader source URL when created via GeoJsonPrimitive.fromUrl.

Methods

static Ditap.GeoJsonPrimitive.fromGeoJson(geoJson, options) → GeoJsonPrimitive

Creates a loader directly from a parsed GeoJSON object.
Name Type Description
geoJson object
options GeoJsonPrimitiveConstructorOptions optional
Returns:

async static Ditap.GeoJsonPrimitive.fromUrl(url, options) → Promise.<GeoJsonPrimitive>

Loads GeoJSON from a URL or Resource.
Name Type Description
url Resource | string
options GeoJsonPrimitiveConstructorOptions optional
Returns:

getId(featureId)

Name Type Description
featureId number

getProperties(featureId)

Name Type Description
featureId number