Ejemplo n.º 1
0
	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);	
	}
Ejemplo n.º 2
0
	void object::test<30>()
	{
		using geos::geom::Coordinate;
		
		const std::size_t size = 5;
		const std::size_t lineSize = 2;

		std::vector<GeometryPtr> lines;

		for (std::size_t i = 0; i < size; ++i)
		{
			const std::size_t factor = i * i;
			CoordArrayPtr coords = new geos::geom::CoordinateArraySequence(lineSize);
			ensure( coords != 0 );
			coords->setAt(Coordinate(0 + factor, 0 + factor), 0);
			coords->setAt(Coordinate(5 + factor, 5 + factor), 1);
			ensure_equals( coords->getSize(), lineSize );

			LineStringPtr line = factory_.createLineString(coords);
			ensure( "createLineString() returned empty point.", !line->isEmpty() );
			ensure_equals( line->getNumPoints(), lineSize );
			ensure( line->isSimple() );
			ensure( line->getCoordinate() != 0 );
			ensure_equals( line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );

			lines.push_back(line);
		}

		MultiLineStringPtr mls = factory_.createMultiLineString(lines);
		ensure( mls != 0 );
		// TODO - mloskot - why isValid() returns false?
		//ensure( mls->isValid() );
		ensure_equals( mls->getNumGeometries(), size );
		ensure_equals( mls->getGeometryTypeId(), geos::geom::GEOS_MULTILINESTRING );

		// FREE MEMORY
		factory_.destroyGeometry(mls);
		std::vector<GeometryPtr>::const_iterator it;
		for (it = lines.begin(); it != lines.end(); ++it)
		{
			delete (*it);
		}
	}
Ejemplo n.º 3
0
	void object::test<15>()
	{
		LineStringPtr line = factory_.createLineString();
		
		ensure( "createLineString() returned null pointer.", line != 0 );
		ensure( "createLineString() returned non-empty point.", line->isEmpty() );
		ensure( line->isSimple() );
		ensure( line->isValid() );
		ensure( line->getCentroid() == 0 );
		
		// TODO - mloskot - waiting for some decision
		// http://geos.refractions.net/pipermail/geos-devel/2006-March/002006.html
		//ensure( line->getCoordinate() == 0 );

		GeometryPtr geo = 0;
		geo = line->getEnvelope();
		ensure( geo != 0 );
		ensure( geo->isEmpty() );
		factory_.destroyGeometry(geo);

		geo = line->getBoundary();
		ensure( geo != 0 );
		ensure( geo->isEmpty() );
		factory_.destroyGeometry(geo);

		geo = line->convexHull();
		ensure( geo != 0 );
		ensure( geo->isEmpty() );
		factory_.destroyGeometry(geo);

		ensure_equals( line->getGeometryTypeId(), geos::geom::GEOS_LINESTRING );
		ensure_equals( line->getDimension(), geos::geom::Dimension::L );
		ensure_equals( line->getBoundaryDimension(), geos::geom::Dimension::P ); // empty linestring
		ensure_equals( line->getNumPoints(), 0u );
		ensure_equals( line->getLength(), 0.0 );
		ensure_equals( line->getArea(), 0.0 );

		// FREE MEMORY
		factory_.destroyGeometry(line);
	}
Ejemplo n.º 4
0
	void object::test<17>()
	{
		const std::size_t size = 5;
		geos::geom::CoordinateArraySequence coords(size);
		ensure_equals( coords.getSize(), size );

		LineStringPtr line = factory_.createLineString(coords);
		ensure( "createLineString() returned empty point.", !line->isEmpty() );
		ensure_equals( line->getNumPoints(), size );
		ensure( line->isSimple() );
		ensure( line->getCoordinate() != 0 );
		
		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);
	}