Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
Aleph::GeomSerializer Class Reference

Serialization utilities for geometry objects. More...

#include <geom_algorithms.H>

Static Public Member Functions

static std::string to_wkt (const Point &p)
 Converts a Point to WKT format: "POINT (x y)".
 
static std::string to_wkt (const Segment &s)
 Converts a Segment to WKT format: "LINESTRING (x1 y1, x2 y2)".
 
static std::string to_wkt (const Triangle &t)
 Converts a Triangle to WKT format: "POLYGON ((x1 y1, x2 y2, x3 y3, x1 y1))".
 
static std::string to_wkt (const Rectangle &r)
 Converts a Rectangle to WKT format: "POLYGON ((xmin ymin, xmax ymin, xmax ymax, xmin ymax, xmin ymin))".
 
static std::string to_wkt (const Polygon &poly)
 Converts a Polygon to WKT format: "POLYGON ((x1 y1, x2 y2, ..., x1 y1))".
 
static std::string to_wkt (const Point3D &p)
 Converts a Point3D to WKT format: "POINT Z (x y z)".
 
static std::string to_geojson (const Point &p)
 Converts a Point to a GeoJSON geometry object.
 
static std::string to_geojson (const Segment &s)
 Converts a Segment to a GeoJSON LineString.
 
static std::string to_geojson (const Triangle &t)
 Triangle → GeoJSON Polygon.
 
static std::string to_geojson (const Polygon &poly)
 Polygon → GeoJSON Polygon.
 
static std::string to_geojson (const Point3D &p)
 Point3D → GeoJSON Point with Z.
 

Static Private Member Functions

static std::string dbl (const Geom_Number &n)
 Formats a Geom_Number as a string with high precision.
 

Detailed Description

Serialization utilities for geometry objects.

Provides conversion to standard text formats:

  • WKT (Well-Known Text): OGC standard for geometry representation.
  • GeoJSON: JSON-based format for geographic data structures.

All numeric values are output as doubles (via geom_number_to_double).

Serializes geometric types to standard string formats (WKT, GeoJSON).

This class provides static methods to convert basic geometric primitives like Point, Segment, Polygon, etc., into Well-Known Text (WKT) and GeoJSON representations.

All numeric values are output as doubles (via geom_number_to_double).

Author
Leandro Rabindranath León
Alejandro J. Mujica

Definition at line 11857 of file geom_algorithms.H.

Member Function Documentation

◆ dbl()

static std::string Aleph::GeomSerializer::dbl ( const Geom_Number n)
inlinestaticprivate

Formats a Geom_Number as a string with high precision.

Definition at line 11862 of file geom_algorithms.H.

References Aleph::divide_and_conquer_partition_dp(), and Aleph::geom_number_to_double().

Referenced by to_geojson(), to_geojson(), to_geojson(), to_geojson(), to_wkt(), to_wkt(), to_wkt(), to_wkt(), and to_wkt().

◆ to_geojson() [1/5]

static std::string Aleph::GeomSerializer::to_geojson ( const Point p)
inlinestatic

Converts a Point to a GeoJSON geometry object.

Definition at line 11960 of file geom_algorithms.H.

References dbl(), Aleph::Point::get_x(), and Aleph::Point::get_y().

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ to_geojson() [2/5]

static std::string Aleph::GeomSerializer::to_geojson ( const Point3D p)
inlinestatic

Point3D → GeoJSON Point with Z.

Definition at line 12018 of file geom_algorithms.H.

References dbl(), Aleph::Point3D::get_x(), Aleph::Point3D::get_y(), and Aleph::Point3D::get_z().

◆ to_geojson() [3/5]

static std::string Aleph::GeomSerializer::to_geojson ( const Polygon poly)
inlinestatic

◆ to_geojson() [4/5]

static std::string Aleph::GeomSerializer::to_geojson ( const Segment s)
inlinestatic

Converts a Segment to a GeoJSON LineString.

Definition at line 11969 of file geom_algorithms.H.

References dbl(), Aleph::Segment::get_src_point(), Aleph::Segment::get_tgt_point(), Aleph::Point::get_x(), and Aleph::Point::get_y().

◆ to_geojson() [5/5]

static std::string Aleph::GeomSerializer::to_geojson ( const Triangle t)
inlinestatic

◆ to_wkt() [1/6]

static std::string Aleph::GeomSerializer::to_wkt ( const Point p)
inlinestatic

Converts a Point to WKT format: "POINT (x y)".

Definition at line 11875 of file geom_algorithms.H.

References dbl(), Aleph::Point::get_x(), and Aleph::Point::get_y().

Referenced by TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().

◆ to_wkt() [2/6]

static std::string Aleph::GeomSerializer::to_wkt ( const Point3D p)
inlinestatic

Converts a Point3D to WKT format: "POINT Z (x y z)".

Definition at line 11949 of file geom_algorithms.H.

References dbl(), Aleph::Point3D::get_x(), Aleph::Point3D::get_y(), and Aleph::Point3D::get_z().

◆ to_wkt() [3/6]

static std::string Aleph::GeomSerializer::to_wkt ( const Polygon poly)
inlinestatic

Converts a Polygon to WKT format: "POLYGON ((x1 y1, x2 y2, ..., x1 y1))".

Definition at line 11921 of file geom_algorithms.H.

References Aleph::divide_and_conquer_partition_dp(), Aleph::geom_number_to_double(), Aleph::Point::get_x(), Aleph::Point::get_y(), and Aleph::Dlink::Iterator::has_curr().

◆ to_wkt() [4/6]

static std::string Aleph::GeomSerializer::to_wkt ( const Rectangle r)
inlinestatic

Converts a Rectangle to WKT format: "POLYGON ((xmin ymin, xmax ymin, xmax ymax, xmin ymax, xmin ymin))".

Definition at line 11908 of file geom_algorithms.H.

References dbl(), and r.

◆ to_wkt() [5/6]

static std::string Aleph::GeomSerializer::to_wkt ( const Segment s)
inlinestatic

Converts a Segment to WKT format: "LINESTRING (x1 y1, x2 y2)".

Definition at line 11883 of file geom_algorithms.H.

References dbl(), Aleph::Segment::get_src_point(), Aleph::Segment::get_tgt_point(), Aleph::Point::get_x(), and Aleph::Point::get_y().

◆ to_wkt() [6/6]

static std::string Aleph::GeomSerializer::to_wkt ( const Triangle t)
inlinestatic

Converts a Triangle to WKT format: "POLYGON ((x1 y1, x2 y2, x3 y3, x1 y1))".

Definition at line 11895 of file geom_algorithms.H.

References dbl(), Aleph::Triangle::get_p1(), Aleph::Triangle::get_p2(), and Aleph::Triangle::get_p3().


The documentation for this class was generated from the following file: