Ejemplo n.º 1
0
/*private*/
void
OffsetCurveSetBuilder::add(const Geometry& g)
{
	if (g.isEmpty()) return;

	const Polygon *poly = dynamic_cast<const Polygon *>(&g);
	if ( poly ) {
		addPolygon(poly);
		return;
	}

	const LineString *line = dynamic_cast<const LineString *>(&g);
	if ( line ) {
		addLineString(line);
		return;
	}

	const Point *point = dynamic_cast<const Point *>(&g);
	if ( point ) {
		addPoint(point);
		return;
	}

	const GeometryCollection *collection = dynamic_cast<const GeometryCollection *>(&g);
	if ( collection ) {
		addCollection(collection);
		return;
	}

	std::string out=typeid(g).name();
	throw util::UnsupportedOperationException("GeometryGraph::add(Geometry &): unknown geometry type: "+out);
}
void
GeometryGraph::add(const Geometry *g)
	//throw (UnsupportedOperationException *)
{
	if (g->isEmpty()) return;

	// check if this Geometry should obey the Boundary Determination Rule
	// all collections except MultiPolygons obey the rule
	if ( dynamic_cast<const MultiPolygon*>(g) )
		useBoundaryDeterminationRule = false;


	if ( dynamic_cast<const Polygon*>(g) )
		addPolygon((Polygon*) g);

	// LineString also handles LinearRings
	else if ( dynamic_cast<const LineString*>(g) )
		addLineString((LineString*) g);

	else if ( dynamic_cast<const Point*>(g) )
		addPoint((Point*) g);

	else if ( dynamic_cast<const MultiPoint*>(g) )
		addCollection((MultiPoint*) g);

	else if ( dynamic_cast<const MultiLineString*>(g) )
		addCollection((MultiLineString*) g);

	else if ( dynamic_cast<const MultiPolygon*>(g) )
		addCollection((MultiPolygon*) g);

	else if ( dynamic_cast<const GeometryCollection*>(g) )
		addCollection((GeometryCollection*) g);

	else {
		string out=typeid(*g).name();
		throw util::UnsupportedOperationException("GeometryGraph::add(Geometry *): unknown geometry type: "+out);
	}
}