本文整理汇总了C++中CoordArrayPtr类的典型用法代码示例。如果您正苦于以下问题:C++ CoordArrayPtr类的具体用法?C++ CoordArrayPtr怎么用?C++ CoordArrayPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CoordArrayPtr类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: coord
void object::test<22>()
{
using geos::geom::Coordinate;
// Buffer for geometries
std::vector<GeometryPtr>* vec = new std::vector<GeometryPtr>();
// Add single point
Coordinate coord(x_, y_, z_);
GeometryPtr point = factory_.createPoint(coord);
ensure( point != 0 );
vec->push_back(point);
// Add single LineString
CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(3);
ensure( coords != 0 );
coords->setAt(Coordinate(0, 0), 0);
coords->setAt(Coordinate(5, 5), 1);
coords->setAt(Coordinate(10, 5), 2);
ensure_equals( coords->getSize(), 3u );
GeometryPtr line = factory_.createLineString(coords);
vec->push_back(line);
// Create geometry collection
GeometryColPtr col = factory_.createGeometryCollection(vec);
ensure( coords != 0 );
ensure_equals( col->getGeometryTypeId(), geos::geom::GEOS_GEOMETRYCOLLECTION );
ensure_equals( col->getNumGeometries(), 2u );
// FREE MEMORY
factory_.destroyGeometry(col);
}
示例2: ls
void object::test<3>()
{
// Single-element sequence of coordiantes
CoordArrayPtr pseq = 0;
try
{
pseq = new geos::geom::CoordinateArraySequence();
ensure( "sequence is null pointer.", pseq != 0 );
pseq->add(geos::geom::Coordinate(0, 0, 0));
ensure_equals( pseq->size(), 1u );
// Create incomplete linstring
LineStringAutoPtr ls(factory_.createLineString(pseq));
fail("IllegalArgumentException expected.");
}
catch (geos::util::IllegalArgumentException const& e)
{
// TODO - mloskot - is waiting for "exception-safety" and bugs resolution
// If removed, memory 3 leaks occur
//delete pseq;
const char* msg = e.what(); // OK
ensure( msg != 0 );
}
}
示例3:
void object::test<16>()
{
const std::size_t size = 5;
CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(size);
ensure( coords != 0 );
ensure_equals( coords->getSize(), size );
LineStringPtr line = factory_.createLineString(coords);
ensure( "createLineString() returned null pointer.", line != 0 );
ensure( "createLineString() returned empty point.", !line->isEmpty() );
ensure( line->isSimple() );
ensure( line->getCoordinate() != 0 );
// TODO - mloskot - is this correct?
//ensure( line->isValid() );
ensure_equals( line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
ensure_equals( line->getDimension(), geos::geom::Dimension::L );
ensure_equals( line->getBoundaryDimension(), geos::geom::Dimension::False );
ensure_equals( line->getNumPoints(), size );
ensure_equals( line->getLength(), 0.0 );
ensure_equals( line->getArea(), 0.0 );
// FREE MEMORY
factory_.destroyGeometry(line);
}
示例4: examplar
void object::test<4>()
{
using geos::geom::Coordinate;
// Non-empty sequence of coordiantes
const size_t size = 3;
CoordArrayPtr pseq = new geos::geom::CoordinateArraySequence();
ensure( "sequence is null pointer.", pseq != 0 );
pseq->add(Coordinate(0, 0, 0));
pseq->add(Coordinate(5, 5, 5));
pseq->add(Coordinate(10, 10, 10));
ensure_equals( pseq->size(), size );
// Create examplar of linstring instance
LineStringAutoPtr examplar(factory_.createLineString(pseq));
// Create copy
LineStringAutoPtr copy(dynamic_cast<geos::geom::LineString*>(examplar->clone()));
ensure( 0 != copy.get() );
ensure( !copy->isEmpty() );
ensure( copy->isSimple() );
ensure( copy->isValid() );
ensure( !copy->isClosed() );
ensure( !copy->isRing() );
GeometryPtr geo = 0;
geo = copy->getEnvelope();
ensure( geo != 0 );
ensure( !geo->isEmpty() );
factory_.destroyGeometry(geo);
geo = copy->getBoundary();
ensure( geo != 0 );
ensure( !geo->isEmpty() );
factory_.destroyGeometry(geo);
geo = copy->convexHull();
ensure( geo != 0 );
ensure( !geo->isEmpty() );
factory_.destroyGeometry(geo);
ensure_equals( copy->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
ensure_equals( copy->getDimension(), geos::geom::Dimension::L );
ensure_equals( copy->getBoundaryDimension(), geos::geom::Dimension::P );
ensure_equals( copy->getNumPoints(), size );
ensure_equals( copy->getArea(), 0.0 );
ensure( copy->getLength() != 0.0 );
}
示例5: poly
void object::test<1>()
{
using geos::geom::Coordinate;
// Create non-empty Coordiantes sequence for Exterior LinearRing
const size_t size = 7;
CoordArrayPtr coords = new geos::geom::CoordinateArraySequence();
ensure( "sequence is null pointer.", coords != nullptr );
coords->add(Coordinate(0, 10));
coords->add(Coordinate(5, 5));
coords->add(Coordinate(10, 5));
coords->add(Coordinate(15, 10));
coords->add(Coordinate(10, 15));
coords->add(Coordinate(5, 15));
coords->add(Coordinate(0, 10));
ensure_equals( coords->size(), size );
try
{
// Create non-empty LinearRing instance
geos::geom::LinearRing ring(coords, factory_.get());
ensure( !ring.isEmpty() );
ensure( ring.isClosed() );
ensure( ring.isRing() );
ensure( ring.isSimple() );
// Exterior (clone is required here because Polygon takes ownership)
GeometryPtr geo = ring.clone();
LinearRingPtr exterior = dynamic_cast<LinearRingPtr>(geo);
// Create non-empty Polygon
//geos::geom::Polygon poly(exterior, 0, &factory_);
PolygonAutoPtr poly(factory_->createPolygon(exterior, nullptr));
ensure( !poly->isEmpty() );
ensure( poly->isSimple() );
ensure( poly->isValid() );
ensure_equals( poly->getNumGeometries(), 1u );
ensure_equals( poly->getNumInteriorRing(), 0u );
ensure_equals( poly->getNumPoints(), size );
}
catch (geos::util::IllegalArgumentException const& e)
{
fail(e.what());
}
}