Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geos36 #636

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 27 additions & 9 deletions geometry-builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ void coords2nodes(CoordinateSequence * coords, nodelist_t &nodes)
}
}

coord_ptr nodes2coords(GeometryFactory &gf, const nodelist_t &nodes)
coord_ptr nodes2coords(const GeometryFactory &gf, const nodelist_t &nodes)
{
coord_ptr coords(gf.getCoordinateSequenceFactory()->create(size_t(0), size_t(2)));

Expand All @@ -85,7 +85,7 @@ coord_ptr nodes2coords(GeometryFactory &gf, const nodelist_t &nodes)
return coords;
}

geom_ptr create_multi_line(GeometryFactory &gf, const multinodelist_t &xnodes)
geom_ptr create_multi_line(const GeometryFactory &gf, const multinodelist_t &xnodes)
{
// XXX leaks memory if an exception is thrown
std::unique_ptr<std::vector<Geometry*> > lines(new std::vector<Geometry*>);
Expand Down Expand Up @@ -202,7 +202,7 @@ void geometry_builder::pg_geom_t::set(const geos::geom::Geometry *g, bool poly,
}
}

geom_ptr geometry_builder::create_simple_poly(GeometryFactory &gf,
geom_ptr geometry_builder::create_simple_poly(const GeometryFactory &gf,
std::unique_ptr<CoordinateSequence> coords) const
{
std::unique_ptr<LinearRing> shell(gf.createLinearRing(coords.release()));
Expand All @@ -227,7 +227,10 @@ geometry_builder::pg_geom_t geometry_builder::get_wkb_simple(const nodelist_t &n

try
{
GeometryFactory gf;
// geos36 - auto-allocation no longer supported in GEOS 3.6+
const GeometryFactory *gf_p = GeometryFactory::getDefaultInstance();
const GeometryFactory& gf = *gf_p;

auto coords = nodes2coords(gf, nodes);
if (polygon && is_polygon_line(coords.get())) {
auto geom = create_simple_poly(gf, std::move(coords));
Expand Down Expand Up @@ -263,7 +266,10 @@ geometry_builder::pg_geoms_t geometry_builder::get_wkb_split(const nodelist_t &n

try
{
GeometryFactory gf;
// geos36 - auto-allocation no longer supported in GEOS 3.6+
const GeometryFactory *gf_p = GeometryFactory::getDefaultInstance();
const GeometryFactory& gf = *gf_p;

auto coords = nodes2coords(gf, nodes);

if (polygon && is_polygon_line(coords.get())) {
Expand Down Expand Up @@ -340,7 +346,10 @@ geometry_builder::pg_geoms_t geometry_builder::get_wkb_split(const nodelist_t &n
}

int geometry_builder::parse_wkb(const char* wkb, multinodelist_t &nodes, bool *polygon) {
GeometryFactory gf;
// geos36 - auto-allocation no longer supported in GEOS 3.6+
const GeometryFactory *gf_p = GeometryFactory::getDefaultInstance();
const GeometryFactory& gf = *gf_p;

geos::io::WKBReader reader(gf);

*polygon = false;
Expand Down Expand Up @@ -395,7 +404,10 @@ geometry_builder::pg_geoms_t geometry_builder::build_polygons(const multinodelis

try
{
GeometryFactory gf;
// geos36 - auto-allocation no longer supported in GEOS 3.6+
const GeometryFactory *gf_p = GeometryFactory::getDefaultInstance();
const GeometryFactory& gf = *gf_p;

geom_ptr mline = create_multi_line(gf, xnodes);

//geom_ptr noded (segment->Union(mline.get()));
Expand Down Expand Up @@ -533,7 +545,10 @@ geometry_builder::pg_geom_t geometry_builder::build_multilines(const multinodeli

try
{
GeometryFactory gf;
// geos36 - auto-allocation no longer supported in GEOS 3.6+
const GeometryFactory *gf_p = GeometryFactory::getDefaultInstance();
const GeometryFactory& gf = *gf_p;

geom_ptr mline = create_multi_line(gf, xnodes);

wkb.set(mline.get(), false);
Expand All @@ -557,7 +572,10 @@ geometry_builder::pg_geoms_t geometry_builder::build_both(const multinodelist_t

try
{
GeometryFactory gf;
// geos36 - auto-allocation no longer supported in GEOS 3.6+
const GeometryFactory *gf_p = GeometryFactory::getDefaultInstance();
const GeometryFactory& gf = *gf_p;

geom_ptr mline = create_multi_line(gf, xnodes);
//geom_ptr noded (segment->Union(mline.get()));
LineMerger merger;
Expand Down
2 changes: 1 addition & 1 deletion geometry-builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class geometry_builder

private:
std::unique_ptr<geos::geom::Geometry>
create_simple_poly(geos::geom::GeometryFactory &gf,
create_simple_poly(const geos::geom::GeometryFactory &gf,
std::unique_ptr<geos::geom::CoordinateSequence> coords) const;

bool excludepoly = false;
Expand Down