void object::test<4>() { geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_MULTIPOINT); ensure(0 != GEOSisEmpty_r(handle_, geom1_)); ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_MULTIPOINT); GEOSGeom_destroy(geom1_); geom1_=0; }
void object::test<7>() { geom1_ = GEOSGeom_createEmptyCollection_r(handle_, GEOS_GEOMETRYCOLLECTION); ensure(0 != GEOSisEmpty_r(handle_, geom1_)); ensure_equals(GEOSGeomTypeId_r(handle_, geom1_), GEOS_GEOMETRYCOLLECTION); GEOSGeom_destroy(geom1_); geom1_=0; }
GEOSGeometry *LineAccumulator::as_geom(GEOSContextHandle_t handle) { m_lines.remove_if(degenerate_line); if(m_lines.size() > 1) { //std::cerr << "Checking first & last" << std::endl; Point first, last; first = m_lines.front().front(); last = m_lines.back().back(); //std::cerr << "first: " << first.x << ", " << first.y << std::endl; //std::cerr << "last: " << last.x << ", " << last.y << std::endl; if(close(first.x, last.x) && close(first.y, last.y)) { m_lines.front().pop_front(); m_lines.back().splice(m_lines.back().end(), m_lines.front()); m_lines.pop_front(); } } std::vector<GEOSGeometry *> geoms; std::list<Line>::const_iterator ilines; for(ilines = m_lines.begin(); ilines != m_lines.end(); ++ilines) { std::list<Point>::const_iterator ipoints; int i; GEOSCoordSequence *coords = GEOSCoordSeq_create_r(handle, (*ilines).size(), 2); for(ipoints = (*ilines).begin(), i = 0; ipoints != (*ilines).end(); ++ipoints, ++i) { GEOSCoordSeq_setX_r(handle, coords, i, ipoints->x); GEOSCoordSeq_setY_r(handle, coords, i, ipoints->y); } geoms.push_back(GEOSGeom_createLineString_r(handle, coords)); } GEOSGeometry *geom; if(geoms.empty()) { geom = GEOSGeom_createEmptyCollection_r(handle, GEOS_MULTILINESTRING); } else { geom = GEOSGeom_createCollection_r(handle, GEOS_MULTILINESTRING, &geoms[0], geoms.size()); } return geom; }