primitive
module
This is the primitive
module.
This module contains primitive geometry data structures derived from the ISO 19107 international standard.
Bearing
Bases: ABC
The Bearing data type indicates a direction. The azimuth can take one of two forms forms:
-
a set of angles, one of which is a plane azimuth and the second a measure of altitude (positive above the horizontal, negative below the horizon). above the horizontal, negative below the horizon), essentially by creating a spherical spherical coordinate system;
-
a directional vector derived from the coordinate system at the initial point, a unit vector with the direction associated with the set of angles.
Since the two types of measurement are identical, the azimuth values are the same, but the interpretations will depend on the usage (usually a reference direction, the offset “0”). will depend on usage (usually a reference direction, offset “0”, and a direction of rotation, clockwise).
The value of the Bearing data type can only be valid at the point from
which the measurement is taken. The common “parallel” transformation of
vectors from one point to another is only valid if the
GeometricReferenceSurface
used is planar (i.e. Cartesian and, therefore,
Euclidean). The fundamental problem is that the sphere has no universally
valid 2D world coordinate system for its tangent spaces. Using a fixed
direction reference such as “true north” does allow some translation,
however, if the reference exists and is unique at a given position.
For example, north does not exist at the North Pole and is not unique at
the South Pole.
Azimuths can be measured in both directions, as absolute values (such as true north, see azimuth) or relative (such as “before” or “after”).
Source code in opengis/geometry/primitive.py
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
|
angle: Sequence[Angle]
abstractmethod
property
In this variant of Bearing, generally used for 2D coordinate systems, the first angle (azimuth) is measured from a coordinate axis (usually north) in a clockwise direction, parallel to the tangent plane of the reference surface. Given two angles, the second angle (altitude) generally represents the angle above (for positive angles) or below (for negative angles) a local plane parallel to the tangent plane of the reference surface.
NOTE: 1 or more angles should be returned.
direction: Optional[Vector]
abstractmethod
property
In this variant of Bearing, generally used for 3D coordinate systems, the direction is expressed as an arbitrary vector in the coordinate system.
reference: ReferenceDirection
abstractmethod
property
The reference attribute is the direction from which the azimuth is measured, i.e. the direction of a positive measurement. Most systems can use a negative number to express a measurement opposite to the default rotation.
rotation: Rotation
abstractmethod
property
The rotation attribute specifies the direction from which the azimuth is measured.
__init__(v, reference, rotation)
abstractmethod
The default azimuth constructor considers a non-zero vector at a point and creates an azimuth at that point, with the classic default values for the most common fixed azimuth.
Source code in opengis/geometry/primitive.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
CurveRelativeDirection
Bases: Enum
CurveRelativeDirection
refers to the vectors associated with
a curve. Some common vector directions are:
- tangent, the direction in which the curve points;
- the inverse tangent, i.e. the opposite of the tangent;
- the binormal, the direction towards the center of curvature, i.e.
the inside of the curve;
- the inverse binormal (reverseBiNormal), the opposite of the
binormal, on the outside of the curve;
- leftNormal, to the left of the tangent;
- rightNormal, to the right of the tangent;
- upNormal, relative to the reference surface;
- downNormal, the opposite of upNormal.
These values can be used to extend or replace the 2D directions
of RelativeDirection
.
Source code in opengis/geometry/primitive.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
DirectPosition
Bases: ABC
Holds the coordinates for a position within some coordinate reference system.
Source code in opengis/geometry/primitive.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
coordinate: Sequence[int | float]
abstractmethod
property
A sequence of real numbers that hold the coordinate values for this position in the specified reference system.
coordinate_reference_system: CoordinateReferenceSystem
abstractmethod
property
The coordinate reference system in which the coordinate tuple is given.
dimension: int
abstractmethod
property
The length of coordinate sequence (the number of entries).
Envelope
Bases: ABC
An Envelope
is often referred to as a box or rectangle defining a minimum
enclosing area. Whatever its size, an Envelope
can be represented
unambiguously as two DirectPositions
(coordinate points). To code an
Envelope
, you simply need to code these two points. This is consistent
with all the coordinate systems in ISO 19107:2019. It should be remembered
that, even if the CoordinateSystem is purely spatial without being
globally bijective, the coordinate may not be valid in the associated
coordinate system.
Source code in opengis/geometry/primitive.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
|
lower_corner: DirectPosition
abstractmethod
property
The “lowerCorner” of an Envelope is a coordinate position consisting of all the minimum coordinates for each dimension, for all points within the Envelope.
Math: For each coordinate offset, the corresponding lower corner offset is the minimum of that offset in all direct positions of the original geometry, and the corresponding upper corner offset is the maximum of those same direct positions.
upper_corner: DirectPosition
abstractmethod
property
The “upperCorner” of an Envelope is a coordinate position consisting of all the maximum coordinates for each dimension, for all points within the Envelope.
Offset in all direct positions of the original geometry.
FixedDirection
Bases: Enum
FixedDirection
enumerates common potential fixed reference directions
for azimuth, generally used in reference to the globe, a map,
a coordinate system or a grid. Common values include true north or south,
magnetic north or south, grid north or south (reference to a grid
or projection).
Source code in opengis/geometry/primitive.py
165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
|
Geometry
Bases: TransfiniteSetOfDirectPositions
Geometry is the base class of the geometric object taxonomy, supporting
interfaces common to all geographically referenced geometric objects.
Instances of Geometry
are sets of DirectPosition
attributes in a
particular reference coordinate system. Geometry
can be thought of as an
infinite set of points that satisfies the set operation interfaces for a
set of direct positions constituting a TransfiniteSetOfDirectPositions
(essentially a set defined by a bool
“isIn” operator). As an infinite
collection class cannot be implemented directly, a bool
inclusion test
must be provided by the Geometry
interface. This document focuses on
vector geometry classes, but future developments may use Geometry
as a
base class without modification.
NOTE 1: As a type, Geometry
has neither a well-defined default state
nor a value representation as a data type. As far as these are concerned,
instantiated subclasses of Geometry
do.
NOTE 2: In its current state this abstract class is a partial
implementation of the Geometry
interface described in ISO 19107:2019.
Source code in opengis/geometry/primitive.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
|
coordinate_reference_system: CoordinateReferenceSystem
abstractmethod
property
The coordinate reference system in which the coordinate geometry is given.
is_empty: bool
abstractmethod
property
The boolean is_empty
attribute indicates that the geometric object
instance is the empty set. Since the empty set is unique, all empty
objects are “spatially equivalent” to any other empty object.
As soon as an instance is known to be empty (self.is_empty = True
),
the rest of the information in the object becomes redundant until the
boolean value self.is_empty
is reset to False
.
If the is_empty
attribute is set to True
, the object is locked
until the is_empty
attribute is set to False
. Essentially, setting
the is_empty
attribute to True
changes the behavior (as defined by
its class) of the object to match the Empty
class, defined in
ISO 19107:2019 section 6.4.10.
Point
Bases: Primitive
A Geometry Point instance is a unique location given by a direct position.
Source code in opengis/geometry/primitive.py
475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 |
|
boundary: Geometry
abstractmethod
property
The “boundary” attribute gives the Point's boundary in the form of a
Geometry
reference system. Since a point's boundary is always empty,
the boundary object will always have the value is_empty = TRUE.
position: DirectPosition
abstractmethod
property
The position
attribute gives the location of the Point
in its
reference system. The distinction between Point
and DirectPosition
lies in the fact that Point
as an object instance has an identity
provided by the system, whereas a DirectPosition
instance is a data
type whose only identity is its own value.
bearing(to_point)
abstractmethod
The bearing
operation is similar to vector_to_point
without the
distance information in the vector. It is essentially a constructor
for Bearing
based on this point and a target point.
Source code in opengis/geometry/primitive.py
500 501 502 503 504 505 506 |
|
point_at_distance(bearing)
abstractmethod
The point_at_distance
operation will return a DirectPosition
attribute given a vector in space tangent to the point whose direction
determines a geodesic curve that intersects this DirectPosition
at
a distance equal to the length of the vector. This operation solves
the first geodesic problem.
Source code in opengis/geometry/primitive.py
508 509 510 511 512 513 514 515 516 |
|
vector_to_point(to_point)
abstractmethod
The vector_to_point
operation will return a vector in space tangent
to the point whose direction determines a geodesic curve that
intersects to_point
at a distance equal to the length of the vector.
This operation solves the second geodesic problem.
Source code in opengis/geometry/primitive.py
518 519 520 521 522 523 524 525 |
|
Primitive
Bases: Geometry
A geometry primitive is a related geometric object with a uniform dimension at each interior point. Depending on the spatial dimension of the coordinate space, primitives are made up of the subclasses Point, Curve, Surface and Solid.
Source code in opengis/geometry/primitive.py
456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 |
|
segment: Optional[Sequence[Primitive]]
abstractmethod
property
The segment
role lists the components (smallest primitives of the
same dimension contained) of Primitive, each of which defines aGeometry
portion of the Primitive. The order of the segments is the order in
which they are used to define the Primitive.
ReferenceDirection
Bases: ABC
The ReferenceDirection interface is empty, but must be “implemented” by any data type that can represent a direction (or tangent unit vector) at a point. This leads to a circular, but valid, possibly recursive definition for the Bearing data type.
Source code in opengis/geometry/primitive.py
112 113 114 115 116 117 118 |
|
RelativeDirection
Bases: Enum
RelativeDirection
enumerates common potential relative reference
directions for azimuth, generally used in reference to a moving
vehicle. Common values include front, rear, port (90° left) or
starboard (90° right).
Source code in opengis/geometry/primitive.py
152 153 154 155 156 157 158 159 160 161 162 |
|
Rotation
Bases: Enum
Rotation
enumerates the two potential directions of rotation for an
angular measurement, clockwise and anti-clockwise. These directions
of rotation are considered as seen from above the reference surface.
Source code in opengis/geometry/primitive.py
102 103 104 105 106 107 108 109 |
|
TransfiniteSetOfDirectPositions
Bases: ABC
Many geometry operations are based on simple set theory, which does not
vary according to the cardinality of the sets concerned. Unfortunately,
the term “set” in most programming languages refers to a finite collection
of objects or object identities. The abstract class
TransfiniteSetOfDirectPositions
represents set-theoretic operations that
cannot always be tested by simple enumeration techniques for sets with a
small number of elements.
A TransfiniteSetOfDirectPositions
can be very large in terms of its
number of elements (limited only to a finite number by the use of
finite-precision numerical computation). The collection
{x ∈ R |0 ≤ x ≤ 1}
is logically infinite. On a digital computer, it may consist of only 2^64 objects. That's a lot, but it's not infinite. The term “transfinite” indicates that nothing on a digital computer is truly infinite, but that doesn't prevent it from being too big to process in a reasonable time interval.
Source code in opengis/geometry/primitive.py
372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
|
contains(pt)
abstractmethod
Determine whether a particular DirectPosition
is part of the set.
Each type of Geometry
interface will have to implement this with
the limitations of a computing platform with limited precision.
Let À be a transfinite set of direct positions. Then we have: [x ∈ A] ⇒ [A.contains(x) = TRUE]
Source code in opengis/geometry/primitive.py
395 396 397 398 399 400 401 402 403 404 |
|
Vector
Bases: ABC
The common “vector” in Euclidean spaces can be translated to any point in space because the flat nature of Euclidean space has a universal coordinate system that works at any “starting” point of a vector.
The Vector data type in this document must be associated with a point on the GeometricReferenceSurface, which must be well defined. The directional parts of the vector must also specify the “starting position” of the vector. Where the coordinate system performs well, the generating family of vectors in tangent space is represented in 3D geocentric space by the tangents to the coordinate functions. For example, in a latitude-longitude system, the unit vectors tangent to the constant longitude curves, as well as to the latitude curves, represent a local tangent space basis, except for the poles where the longitude function has a zero tangent. longitude function has a zero tangent at the pole. If (lat, long = (dφ, dλ), then the symbols (dφ, dλ) are the differentials of the two-coordinate functions represented by the tangents in the direction of increasing φ, respectively λ, and represent a basis for local tangent spaces.
Source code in opengis/geometry/primitive.py
273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
coordinate_system: CoordinateSystem
abstractmethod
property
The coordinate_system
attribute is the origin system and, therefore,
determines the coordinates of the local tangent space in which the
vector exists.
dimension: int
abstractmethod
property
The dimension attribute is the dimension of the origin and, consequently, the dimension of the tangent space of the vector.
offsets: Sequence[float]
abstractmethod
property
The offset attribute uses the direct position coordinate system and represents the local tangent vector vector in the local coordinate differentials.
EXAMPLE: If the Euclidean (E²) plane is used, then the DirectPosition
is a pair of coordinates (x, y) and the the vector consists of the
differentials in both directions. Consequently, the offset is of
length 2 and has a coordinate base of (dx, dy).
origin: DirectPosition
abstractmethod
property
The origin attribute is the location of the point on the
GeometricReferenceSurface
for which the vector is a tangent.
The direct position is associated with the coordinate system.
This determines the coordinate system for the vector. The spatial
dimension of the direct position determines the dimension of
the vector.
__init__(position, coordinates=None, direction=None, length=None)
abstractmethod
The constructor vector creates a vector with the given offsets or direction and length at the specified direct position, in the coordinate space of the direct position.
NOTE: if coordinates
is not specified then direction
and length
must be specified. Likewise if direction
or length
is not specified
then coordinates
must be specified.
Source code in opengis/geometry/primitive.py
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 |
|
cross_product(v2)
abstractmethod
The cross product is a third vector perpendicular to the other two. If the vector space is only two-dimensional, the cross product gives an oriented intensity and not a vector.
Source code in opengis/geometry/primitive.py
355 356 357 358 359 360 361 |
|
dot_product(v2)
abstractmethod
The dot product operation yields a real value which is the sum of the products of the corresponding coefficients coefficients of the two vectors.
Source code in opengis/geometry/primitive.py
363 364 365 366 367 368 369 |
|