Example #1
0
void
WKBWriter::writePolygon(const Polygon& g)
{
    writeByteOrder();

    writeGeometryType(WKBConstants::wkbPolygon, g.getSRID());
    writeSRID(g.getSRID());

    if(g.isEmpty()) {
        writeInt(0);
        return;
    }

    std::size_t nholes = g.getNumInteriorRing();
    writeInt(static_cast<int>(nholes + 1));

    const LineString* ls = g.getExteriorRing();
    assert(ls);

    const CoordinateSequence* cs = ls->getCoordinatesRO();
    assert(cs);

    writeCoordinateSequence(*cs, true);
    for(std::size_t i = 0; i < nholes; i++) {
        ls = g.getInteriorRingN(i);
        assert(ls);

        cs = ls->getCoordinatesRO();
        assert(cs);

        writeCoordinateSequence(*cs, true);
    }
}
Example #2
0
void
WKBWriter::writePolygon(const Polygon &g) 
{
	writeByteOrder();
	
	writeGeometryType(WKBConstants::wkbPolygon, g.getSRID());
	writeSRID(g.getSRID());
	
	int nholes = g.getNumInteriorRing();
	writeInt(nholes+1);

	const LineString* ls = g.getExteriorRing();
	assert(ls);

	const CoordinateSequence* cs=ls->getCoordinatesRO();
	assert(cs);

	writeCoordinateSequence(*cs, true);
	for (int i=0; i<nholes; i++)
	{
		ls = g.getInteriorRingN(i);
		assert(ls);

		cs = ls->getCoordinatesRO();
		assert(cs);

		writeCoordinateSequence(*cs, true);
	}
}
Example #3
0
void
WKBWriter::writeLineString(const LineString& g)
{
    writeByteOrder();

    writeGeometryType(WKBConstants::wkbLineString, g.getSRID());
    writeSRID(g.getSRID());

    const CoordinateSequence* cs = g.getCoordinatesRO();
    assert(cs);
    writeCoordinateSequence(*cs, true);
}
Example #4
0
void
WKBWriter::writePoint(const Point& g)
{
    if(g.isEmpty()) throw
        util::IllegalArgumentException("Empty Points cannot be represented in WKB");

    writeByteOrder();

    writeGeometryType(WKBConstants::wkbPoint, g.getSRID());
    writeSRID(g.getSRID());

    const CoordinateSequence* cs = g.getCoordinatesRO();
    assert(cs);
    writeCoordinateSequence(*cs, false);
}
Example #5
0
void
WKBWriter::writeGeometryCollection(const GeometryCollection &g,
	int wkbtype) 
{
	writeByteOrder();
	
	writeGeometryType(wkbtype, g.getSRID());
	writeSRID(g.getSRID());
	
	int ngeoms = g.getNumGeometries();
	writeInt(ngeoms);

	assert(outStream);
	for (int i=0; i<ngeoms; i++)
	{
		const Geometry* elem = g.getGeometryN(i);
		assert(elem);

		write(*elem, *outStream);
	}
}
Example #6
0
void
WKBWriter::writeCircularArc(const CircularArc &g)
{
	writeByteOrder();

	writeGeometryType(WKBConstants::wkbCircularArc, g.getSRID());
	writeSRID(g.getSRID());

	ByteOrderValues::putDouble(g.GetCenterPoint().x, buf, byteOrder);
	outStream->write(reinterpret_cast<char *>(buf), 8);
	ByteOrderValues::putDouble(g.GetCenterPoint().y, buf, byteOrder);
	outStream->write(reinterpret_cast<char *>(buf), 8);

	ByteOrderValues::putDouble(g.GetRadius(), buf, byteOrder);
	outStream->write(reinterpret_cast<char *>(buf), 8);

	ByteOrderValues::putDouble(g.GetStartAngle(), buf, byteOrder);
	outStream->write(reinterpret_cast<char *>(buf), 8);

	ByteOrderValues::putDouble(g.GetCenterAngle(), buf, byteOrder);
	outStream->write(reinterpret_cast<char *>(buf), 8);
}
Example #7
0
void
WKBWriter::writeGeometryCollection(const GeometryCollection& g,
                                   int wkbtype)
{
    writeByteOrder();

    writeGeometryType(wkbtype, g.getSRID());
    writeSRID(g.getSRID());

    auto ngeoms = g.getNumGeometries();
    writeInt(static_cast<int>(ngeoms));
    auto orig_includeSRID = includeSRID;
    includeSRID = false;

    assert(outStream);
    for(std::size_t i = 0; i < ngeoms; i++) {
        const Geometry* elem = g.getGeometryN(i);
        assert(elem);

        write(*elem, *outStream);
    }
    includeSRID = orig_includeSRID;
}