This namespace contains definitions of static functions for common CesiumJS operations wih geometries.
- Source:
- mapspace/util/cesium/util.jsdoc
Members
-
<static, constant> GEOMETRY_TO_ENTITY_CONVERTERS :Object.<string, function(ol.geom.Geometry, Mapspace.MaterialDefinition, string, Cesium.Entity=): (Cesium.Entity|Array.<Cesium.Entity>|null)>
-
- Source:
- mapspace/util/cesium/util.js
-
<static, constant> GEOMETRY_TO_PRIMITIVE_CONVERTERS :Object.<string, function(ol.geom.Geometry, Mapspace.MaterialDefinition): Cesium.Primitive>
-
- Source:
- mapspace/util/cesium/util.js
Methods
-
<static> applyHeightRef(coords, heightRef, inverse)
-
Converts an array of Cartesian coords to a new Cartesian coords but with height reference applied.
Parameters:
Name Type Argument Description coords
Array.<Cesium.Cartesian3> Cartesian coords.
heightRef
number Height reference to apply.
inverse
boolean <nullable>
Height reference is removed, not added. By default is false.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Array.<Cesium.Cartesian3>
-
<static> convertCircleToEntity(geom, materialDef, id)
-
Converts a
ol.geom.Circle
to aCesium.Entity
.Parameters:
Name Type Description geom
ol.geom.Circle The geometry.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the resulting 3D object.
id
string The unique id for the entity.
- Source:
- mapspace/util/cesium/util.js
Returns:
One or several Cesium entities, or null if the conversion could not be done. When several entities are returned the first is an empty one that should be used as parent for the rest. This is useful for multi-geometries.
- Type
- Cesium.Entity | Array.<Cesium.Entity> | null
-
<static> convertCircleToPrimitive(geom, material)
-
Converts a
ol.geom.Circle
to aCesium.Primitive
.Parameters:
Name Type Description geom
ol.geom.Circle The geometry.
material
Object.<string, Object> Material for the output object.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Primitive
-
<static> convertColor(color)
-
Converts an OpenLayers
color
orol.ColorLike
to Cesium.Parameters:
Name Type Description color
ol.color | ol.ColorLike OpenLayers color.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Color
-
<static> convertColorInverse(color, asRGBA)
-
Converts a Cesium color (
Cesium.Color
) to an OpenLayersol.ColorLike
following the patternrba(0-255, 0-255, 0-255, 0-1)
.Parameters:
Name Type Argument Description color
Cesium.Color Cesium color.
asRGBA
boolean <nullable>
If return RGBA (true) or RGB (false). By default is true.
ol.ColorLike - Source:
- mapspace/util/cesium/util.js
-
<static> convertCoordinates(coordinates, heightRef)
-
Convert one or several 2D or 3D
Mapspace.Coordinate
inEPSG:4326
projection to one or severalCesium.Cartesian3
.Parameters:
Name Type Argument Description coordinates
Mapspace.Coordinate | Array.<Mapspace.Coordinate> Coordinates.
heightRef
Mapspace.HeightReference <nullable>
Optional point height reference. By default is set as NONE = 0, that means the height is not altered.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Cartesian3 | Array.<Cesium.Cartesian>
-
<static> convertGeometryCollectionToEntity(geom, materialDef, id [, parent])
-
Converts a
ol.geom.GeometryCollection
inEPSG:4326
projection in aCesium.Entity
.Parameters:
Name Type Argument Description geom
ol.geom.GeometryCollection GeometryCollection.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the resulting 3D object.
id
string The unique id for the entity.
parent
Cesium.Entity <optional>
Optional parent for the resulting entity.
- Source:
- mapspace/util/cesium/util.js
Returns:
One or several Cesium entities, or null if the conversion could not be done. When several entities are returned the first is an empty one that should be used as parent for the rest. This is useful for multi-geometries.
- Type
- Cesium.Entity | Array.<Cesium.Entity> | null
-
<static> convertGeometryCollectionToPrimitive(geom, material)
-
Converts a
ol.geom.GeometryCollection
in aCesium.Primitive
.Parameters:
Name Type Description geom
ol.geom.GeometryCollection GeometryCollection.
material
Object.<string, Object> Material for the output object.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Primitive
-
<static> convertGeometryToEntity(geometry, materialDef, ignoreHoles, id [, projection])
-
Converts a
ol.geom.Geometry
to aCesium.Entity
. It returns null if geometry is undefined.Parameters:
Name Type Argument Description geometry
ol.geom.Geometry OpenLayers geometry.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the resulting 3D object.
ignoreHoles
boolean If ignore interior rings for Polygon objects. This is because certain formats as Shapefile can give problems reading them.
id
string The unique id for the entity.
projection
ol.ProjectionLike <optional>
Optional projection. If not exist then by default the geometry is supposed to be in
EPSG:4326
.- Source:
- mapspace/util/cesium/util.js
Returns:
One or several Cesium entities, or null if the conversion could not be done. When several entities are returned the first is an empty one that should be used as parent for the rest. This is useful for multi-geometries.
- Type
- Cesium.Entity | Array.<Cesium.Entity> | null
-
<static> convertGeometryToPrimitive(geometry, material, ignoreHoles [, projection])
-
Converts a
ol.geom.Geometry
to aCesium.Primitive
. It returns null if geometry is undefined.Parameters:
Name Type Argument Description geometry
ol.geom.Geometry OpenLayers geometry.
material
Object.<string, Object> Material for the output object.
ignoreHoles
boolean If ignore interior rings for Polygon objects. This is because certain formats as Shapefile can give problems reading them.
projection
ol.ProjectionLike <optional>
Optional projection. If not exist then by default the geometry is supposed to be in EPSG:4326.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Primitive
-
<static> convertLineStringToEntity(geom, materialDef, id [, parent])
-
Converts a
ol.geom.LineString
inEPSG:4326
projection in aCesium.Entity
.Parameters:
Name Type Argument Description geom
ol.geom.LineString | ol.geom.LinearRing LineString or LinearRing.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the resulting 3D object.
id
string The unique id for the entity.
parent
Cesium.Entity <optional>
Optional parent for the resulting entity.
- Source:
- mapspace/util/cesium/util.js
Returns:
One or several Cesium entities, or null if the conversion could not be done. When several entities are returned the first is an empty one that should be used as parent for the rest. This is useful for multi-geometries.
- Type
- Cesium.Entity | Array.<Cesium.Entity> | null
-
<static> convertLineStringToPrimitive(geom, material)
-
Converts a
ol.geom.LineString
in aCesium.Primitive
.Parameters:
Name Type Description geom
ol.geom.LineString | ol.geom.LinearRing LineString or LinearRing.
material
Object.<string, Object> Material for the output object.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Primitive
-
<static> convertMultiLineStringToEntity(geom, materialDef, id [, parent])
-
Converts a
ol.geom.MultiLineString
inEPSG:4326
projection in aCesium.Entity
.Parameters:
Name Type Argument Description geom
ol.geom.MultiLineString MultiLineString.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the resulting 3D object.
id
string The unique id for the entity.
parent
Cesium.Entity <optional>
Optional parent for the resulting entity.
- Source:
- mapspace/util/cesium/util.js
Returns:
One or several Cesium entities, or null if the conversion could not be done. When several entities are returned the first is an empty one that should be used as parent for the rest. This is useful for multi-geometries.
- Type
- Cesium.Entity | Array.<Cesium.Entity> | null
-
<static> convertMultiLineStringToPrimitive(geom, material)
-
Converts a
ol.geom.MultiLineString
in aCesium.Primitive
.Parameters:
Name Type Description geom
ol.geom.MultiLineString MultiLineString.
material
Object.<string, Object> Material for the output object.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Primitive
-
<static> convertMultiPointToEntity(geom, materialDef, id [, parent])
-
Converts a
ol.geom.MultiPoint
inEPSG:4326
projection in aCesium.Entity
.Parameters:
Name Type Argument Description geom
ol.geom.MultiPoint MultiPoint.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the resulting 3D object.
id
string The unique id for the entity.
parent
Cesium.Entity <optional>
Optional parent for the resulting entity.
- Source:
- mapspace/util/cesium/util.js
Returns:
One or several Cesium entities, or null if the conversion could not be done. When several entities are returned the first is an empty one that should be used as parent for the rest. This is useful for multi-geometries.
- Type
- Cesium.Entity | Array.<Cesium.Entity> | null
-
<static> convertMultiPointToPrimitive(geom, material)
-
Converts a
ol.geom.MultiPoint
in aCesium.Primitive
.Parameters:
Name Type Description geom
ol.geom.MultiPoint MultiPoint.
material
Object.<string, Object> Material for the output object.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Primitive
-
<static> convertMultiPolygonToEntity(geom, materialDef, id [, parent])
-
Converts a
ol.geom.MultiPolygon
inEPSG:4326
projection in aCesium.Entity
.Parameters:
Name Type Argument Description geom
ol.geom.MultiPolygon MultiPolygon.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the resulting 3D object.
id
string The unique id for the entity.
parent
Cesium.Entity <optional>
Optional parent for the resulting entity.
- Source:
- mapspace/util/cesium/util.js
Returns:
One or several Cesium entities, or null if the conversion could not be done. When several entities are returned the first is an empty one that should be used as parent for the rest. This is useful for multi-geometries.
- Type
- Cesium.Entity | Array.<Cesium.Entity> | null
-
<static> convertMultiPolygonToPrimitive(geom, material)
-
Converts a
ol.geom.MultiPolygon
in aCesium.Primitive
.Parameters:
Name Type Description geom
ol.geom.MultiPolygon MultiPolygon.
material
Object.<string, Object> Material for the output object.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Primitive
-
<static> convertPointToEntity(geom, materialDef, id [, parent])
-
Converts a
ol.geom.Point
inEPSG:4326
projection in aCesium.Entity
.Parameters:
Name Type Argument Description geom
ol.geom.Point Point.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the resulting 3D object.
id
string The unique id for the entity.
parent
Cesium.Entity <optional>
Optional parent for the resulting entity.
- Source:
- mapspace/util/cesium/util.js
Returns:
One or several Cesium entities, or null if the conversion could not be done. When several entities are returned the first is an empty one that should be used as parent for the rest. This is useful for multi-geometries.
- Type
- Cesium.Entity | Array.<Cesium.Entity> | null
-
<static> convertPointToPrimitive(geom, material)
-
Converts a
ol.geom.Point
in EPSG:4326 projection in aCesium.Primitive
.Parameters:
Name Type Description geom
ol.geom.Point Point.
material
Object.<string, Object> Material for the output object.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Primitive
-
<static> convertPolygonToEntity(geom, materialDef, id [, parent])
-
Converts a
ol.geom.Polygon
inEPSG:4326
projection in aCesium.Entity
.Parameters:
Name Type Argument Description geom
ol.geom.Polygon Polygon.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the resulting 3D object.
id
string The unique id for the entity.
parent
Cesium.Entity <optional>
Optional parent for the resulting entity.
- Source:
- mapspace/util/cesium/util.js
Returns:
One or several Cesium entities, or null if the conversion could not be done. When several entities are returned the first is an empty one that should be used as parent for the rest. This is useful for multi-geometries.
- Type
- Cesium.Entity | Array.<Cesium.Entity> | null
-
<static> convertPolygonToOptions(geom, pointHeight)
-
Converts a polygon to an options object used by Cesium. If polygon has no external ring returns null.
Parameters:
Name Type Description geom
ol.geom.Polygon Polygon.
pointHeight
Mapspace.PointReference Point height style.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Object
-
<static> convertPolygonToPrimitive(geom, material)
-
Converts a
ol.geom.Polygon
in aCesium.Primitive
.Parameters:
Name Type Description geom
ol.geom.Polygon Polygon.
material
Object.<string, Object> Material for the output object.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Primitive
-
<static> convertStyleToMaterialDefinition(style, heightStyle)
-
Converts a
ol.style.Style
to aMapspace.MaterialDefinition
.Parameters:
Name Type Argument Description style
ol.style.Style OpenLayers style.
heightStyle
Mapspace.HeightReference <nullable>
Optional point height style. By default is set as NONE = 0, that means the height is not altered.
- Source:
- mapspace/util/cesium/util.js
Returns:
-
<static> coplanarizeCoordinates(coords, coplanarity, ring)
-
Returns a new array of coordinates in
EPSG:4326
projection from given ones ensuring that coplanarity constraints are followed in the returned array, stopping the array in the first coordinate that cannot be forced to comply with, excluding it and above from the result.Parameters:
Name Type Description coords
Array.<Mapspace.Coordinate> The input coordinates in
EPSG:4326
projection.coplanarity
Mapspace.CoplanarityType If points must be enforced to be coplanar and what type of coplanarity to enforce. To ignore this use
NONE
. To enforce that all points are in a vertical plane, useVERTICAL
. In this case the first two coordinates that are not vertically overlapped will be used to define a plane. To enforce that all points are in a horizontal plane, useHORIZONTAL
. In this case the first point will define a plane using its height. To enforce any other coplanarity, useANY
. In this case the first three not-coincident points will be used to define a plane.ring
boolean If the coordinates are a linear ring, so last vertex must be ensured to be the same as first one.
- Source:
- mapspace/util/cesium/util.js
Returns:
A new coordinates but modified, in
EPSG:4326
projection.- Type
- Array.<Mapspace.Coordinate>
-
<static> createLabelEntity(coord, label, showLabel)
-
Creates a label entity.
Parameters:
Name Type Description coord
Mapspace.Coordinate The coordinates for the label in
EPSG:4326
.label
string String with the text in the label.
showLabel
boolean If show the label or not.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- Cesium.Entity
-
<static> fromCartesianToMercator(coordinate)
-
Converts coordinate from cartesian to mercator.
Parameters:
Name Type Description coordinate
Mapspace.Coordinate Cartesian coordinate.
- Source:
- mapspace/util/cesium/util.js
Returns:
Mercator coordinate.
- Type
- Mapspace.Coordinate
-
<static> fromIconTypeToSVG(pointType, fillColor, fillOpacity, outlineColor, outlineOpacity, outlineWidth)
-
Returns a SVG string to be used in a billboard given the icon type.
Parameters:
Name Type Description pointType
Mapspace.PointIconType Icon type.
fillColor
ol.ColorLike Fill color.
fillOpacity
number Fill opacity from 0 (transparent) to 1 (opaque).
outlineColor
ol.ColorLike Outline color.
outlineOpacity
number Outline opacity from 0 (transparent) to 1 (opaque).
outlineWidth
number Outline width in pixels.
- Source:
- mapspace/util/cesium/util.js
Returns:
- Type
- string
-
<static> fromMercatorToCartesian(coordinate)
-
Converts coordinate from mercator to cartesian.
Parameters:
Name Type Description coordinate
Mapspace.Coordinate Mercator coordinate.
- Source:
- mapspace/util/cesium/util.js
Returns:
Cartesian coordinate.
- Type
- Mapspace.Coordinate
-
<static> getMixedMaterialDefinition(matDef, matDef2)
-
Returns a new
Mapspace.MaterialDefinition
that has colors from matDef2 and the rest of the properties from matDef. This is useful to set a material definition that makes any object as selected or interacted.Parameters:
Name Type Description matDef
Mapspace.MaterialDefinition Current material definition applied.
matDef2
Mapspace.MaterialDefinition Material definition that contains the colors to be used instead of colors from matDef.
- Source:
- mapspace/util/cesium/util.js
Returns:
-
<static> toLocalGeometry(feature, heightRef, localCoords)
-
Returns a new geometry but transformed from Mercator Spheric coordinates to local cartesian coordinates (these are the coordinates that can be drawn in a Cesium viewer).
Parameters:
Name Type Argument Description feature
ol.Feature Feature with geometry in Mercator Spheric coordinates.
heightRef
number <nullable>
Optional height reference to apply.
localCoords
Array.<ol.Coordinate> <nullable>
An optional array where store the coordinates of the geometry in local cartesian coordinates.
- Source:
- mapspace/util/cesium/util.js
Returns:
The geometry in local cartesian coordinates.
- Type
- ol.geom.Geometry
-
<static> updateEntity(entity, materialDef, geom)
-
Updates a
Cesium.Entity
to use new properties in the given material definition and geometry.Parameters:
Name Type Description entity
Cesium.Entity The entity to modify.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the entity.
geom
ol.geom.Geometry The geometry to apply to the entity.
- Source:
- mapspace/util/cesium/util.js
-
<static> updateFeatureEntities(feature, entities, materialDef, opt_geom)
-
Updates the entities related to a given feature to use the new properties in the given material definition.
Parameters:
Name Type Description feature
ol.Feature Feature.
entities
Array.<Cesium.Entity> All the entities available in the layer that contains the feature.
materialDef
Mapspace.MaterialDefinition The material definition to apply to the entity.
opt_geom
ol.geom.Geometry Optional geometry to use instead of the geometry in the feature.
- Source:
- mapspace/util/cesium/util.js