diff --git a/plugins/input/geos/SConscript b/plugins/input/geos/SConscript index 5bfbe7dd0..8c6b30516 100644 --- a/plugins/input/geos/SConscript +++ b/plugins/input/geos/SConscript @@ -27,7 +27,6 @@ install_prefix = env['DESTDIR'] + '/' + prefix geos_src = Split( """ - geos_converter.cpp geos_datasource.cpp geos_featureset.cpp """ diff --git a/plugins/input/geos/geos_converter.cpp b/plugins/input/geos/geos_converter.cpp deleted file mode 100644 index f0ca3c657..000000000 --- a/plugins/input/geos/geos_converter.cpp +++ /dev/null @@ -1,449 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2010 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ -//$Id$ - -#include -#include -#include -#include -#include -#include -#include - -// geos -#include "geos_converter.hpp" - -using std::clog; -using std::endl; - -using mapnik::feature_ptr; -using mapnik::geometry_utils; -using mapnik::geometry_type; - - -void geos_converter::convert_geometry (const GEOSGeometry* geom, feature_ptr feature, bool multiple_geometries) -{ - int type = GEOSGeomTypeId(geom); - - switch ( type ) - { - case GEOS_POINT: - convert_point (geom, feature); - break; - case GEOS_LINESTRING: - case GEOS_LINEARRING: - convert_linestring (geom, feature); - break; - case GEOS_POLYGON: - convert_polygon (geom, feature); - break; - case GEOS_MULTIPOINT: - if (multiple_geometries) - convert_multipoint_2 (geom, feature); - else - // Todo - using convert_multipoint_2 until we have proper multipoint handling in convert_multipoint - // http://trac.mapnik.org/ticket/458 - //convert_multipoint (geom, feature); - convert_multipoint_2 (geom, feature); - break; - case GEOS_MULTILINESTRING: - if (multiple_geometries) - convert_multilinestring_2 (geom, feature); - else - convert_multilinestring (geom, feature); - break; - case GEOS_MULTIPOLYGON: - if (multiple_geometries) - convert_multipolygon_2 (geom, feature); - else - convert_multipolygon (geom, feature); - break; - case GEOS_GEOMETRYCOLLECTION: - convert_collection (geom, feature, multiple_geometries); - break; - default: -#ifdef MAPNIK_DEBUG - clog << "unknown geometry_type=" << type << endl; -#endif - break; - } -} - -void geos_converter::convert_point (const GEOSGeometry* geom, feature_ptr feature) -{ -#ifdef MAPNIK_DEBUG - clog << "convert_point" << endl; -#endif - - double x, y; - unsigned int size; - - const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq(geom); - - GEOSCoordSeq_getSize(cs, &size); - GEOSCoordSeq_getX(cs, 0, &x); - GEOSCoordSeq_getY(cs, 0, &y); - - geometry_type* point = new geometry_type(mapnik::Point); - point->move_to (x, y); - - feature->add_geometry (point); -} - -void geos_converter::convert_linestring (const GEOSGeometry* geom, feature_ptr feature) -{ -#ifdef MAPNIK_DEBUG - clog << "convert_linestring" << endl; -#endif - - double x, y; - unsigned int num_points; - - const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq(geom); - - GEOSCoordSeq_getSize(cs, &num_points); - GEOSCoordSeq_getX(cs, 0, &x); - GEOSCoordSeq_getY(cs, 0, &y); - - geometry_type* line = new geometry_type(mapnik::LineString); - line->set_capacity (num_points); - line->move_to (x, y); - - for (unsigned int i = 1; i < num_points; ++i) - { - GEOSCoordSeq_getX(cs, i, &x); - GEOSCoordSeq_getY(cs, i, &y); - line->line_to (x, y); - } - - feature->add_geometry (line); -} - -void geos_converter::convert_polygon (const GEOSGeometry* geom, feature_ptr feature) -{ -#ifdef MAPNIK_DEBUG - clog << "convert_polygon" << endl; -#endif - - double x, y; - unsigned int num_points, num_interior; - - const GEOSGeometry* exterior = GEOSGetExteriorRing(geom); - const GEOSCoordSequence* es = GEOSGeom_getCoordSeq(exterior); - GEOSCoordSeq_getSize(es, &num_points); - GEOSCoordSeq_getX(es, 0, &x); - GEOSCoordSeq_getY(es, 0, &y); - - num_interior = GEOSGetNumInteriorRings(geom); - - unsigned int capacity = 0; - for (unsigned int r = 0; r < num_interior; r++) - { - const GEOSGeometry* gtmp = GEOSGetInteriorRingN(geom, r); - const GEOSCoordSequence* is = GEOSGeom_getCoordSeq(gtmp); - - unsigned int interior_size; - GEOSCoordSeq_getSize(is, &interior_size); - - capacity += interior_size; - } - - geometry_type* poly = new geometry_type(mapnik::Polygon); - poly->set_capacity (num_points + capacity); - poly->move_to (x, y); - for (unsigned int i = 1; i < num_points; ++i) - { - GEOSCoordSeq_getX(es, i, &x); - GEOSCoordSeq_getY(es, i, &y); - - poly->line_to (x, y); - } - for (unsigned int r = 0; r < num_interior; ++r) - { - const GEOSGeometry* gtmp = GEOSGetInteriorRingN(geom, r); - const GEOSCoordSequence* is = GEOSGeom_getCoordSeq(gtmp); - - GEOSCoordSeq_getSize(is, &num_points); - GEOSCoordSeq_getX(is, 0, &x); - GEOSCoordSeq_getY(is, 0, &y); - - poly->move_to(x, y); - for (unsigned int i = 1; i < num_points; ++i) - { - GEOSCoordSeq_getX(is, i, &x); - GEOSCoordSeq_getY(is, i, &y); - - poly->line_to(x, y); - } - } - - feature->add_geometry (poly); -} - -void geos_converter::convert_multipoint (const GEOSGeometry* geom, feature_ptr feature) -{ -#ifdef MAPNIK_DEBUG - clog << "convert_multipoint" << endl; -#endif - - unsigned int num_geometries = GEOSGetNumGeometries(geom); - geometry_type* point = new geometry_type(mapnik::Point); - - for (unsigned int i = 0; i < num_geometries; i++) - { - const GEOSGeometry* g = GEOSGetGeometryN(geom, i); - - if (g != NULL && GEOSisValid(g)) - { - const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq(g); - - double x, y; - //GEOSCoordSeq_getSize(cs, &size); - GEOSCoordSeq_getX(cs, 0, &x); - GEOSCoordSeq_getY(cs, 0, &y); - - point->move_to (x, y); - } - } - - feature->add_geometry (point); -} - -void geos_converter::convert_multipoint_2 (const GEOSGeometry* geom, feature_ptr feature) -{ -#ifdef MAPNIK_DEBUG - clog << "convert_multipoint_2" << endl; -#endif - - unsigned int num_geometries = GEOSGetNumGeometries(geom); - - for (unsigned int i = 0; i < num_geometries; ++i) - { - const GEOSGeometry* g = GEOSGetGeometryN(geom, i); - - if (g != NULL && GEOSisValid(g)) - { - convert_point (g, feature); - } - } -} - -void geos_converter::convert_multilinestring (const GEOSGeometry* geom, feature_ptr feature) -{ -#ifdef MAPNIK_DEBUG - clog << "convert_multilinestring" << endl; -#endif - - double x, y; - unsigned int num_points = 0; - - unsigned int num_geometries = GEOSGetNumGeometries(geom); - - for (unsigned int i = 0; i < num_geometries; ++i) - { - const GEOSGeometry* g = GEOSGetGeometryN(geom, i); - - if (g != NULL && GEOSisValid(g)) - { - const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq(g); - - unsigned int temp_points; - GEOSCoordSeq_getSize(cs, &temp_points); - - num_points += temp_points; - } - } - - - geometry_type* line = new geometry_type(mapnik::LineString); - line->set_capacity (num_points); - - for (unsigned int i = 0; i < num_geometries; ++i) - { - const GEOSGeometry* g = GEOSGetGeometryN(geom, i); - - if (g != NULL && GEOSisValid(g)) - { - const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq(g); - - GEOSCoordSeq_getSize(cs, &num_points); - GEOSCoordSeq_getX(cs, 0, &x); - GEOSCoordSeq_getY(cs, 0, &y); - - line->move_to (x, y); - - for (unsigned int i = 1; i < num_points; ++i) - { - GEOSCoordSeq_getX(cs, i, &x); - GEOSCoordSeq_getY(cs, i, &y); - line->line_to (x, y); - } - } - } - - feature->add_geometry (line); -} - -void geos_converter::convert_multilinestring_2 (const GEOSGeometry* geom, feature_ptr feature) -{ -#ifdef MAPNIK_DEBUG - clog << "convert_multilinestring_2" << endl; -#endif - - unsigned int num_geometries = GEOSGetNumGeometries(geom); - - for (unsigned int i = 0; i < num_geometries; ++i) - { - const GEOSGeometry* g = GEOSGetGeometryN(geom, i); - - if (g != NULL && GEOSisValid(g)) - { - convert_linestring (g, feature); - } - } -} - -void geos_converter::convert_multipolygon (const GEOSGeometry* geom, feature_ptr feature) -{ -#ifdef MAPNIK_DEBUG - clog << "convert_multipolygon" << endl; -#endif - - double x, y; - unsigned int num_points, num_interior; - unsigned int capacity = 0; - - unsigned int num_geometries = GEOSGetNumGeometries(geom); - - for (unsigned int i = 0; i < num_geometries; ++i) - { - const GEOSGeometry* g = GEOSGetGeometryN(geom, i); - - if (g != NULL && GEOSisValid(g)) - { - const GEOSGeometry* exterior = GEOSGetExteriorRing(g); - const GEOSCoordSequence* es = GEOSGeom_getCoordSeq(exterior); - GEOSCoordSeq_getSize(es, &num_points); - - capacity += num_points; - - num_interior = GEOSGetNumInteriorRings(g); - for (unsigned int r = 0; r < num_interior; r++) - { - const GEOSGeometry* gtmp = GEOSGetInteriorRingN(g, r); - const GEOSCoordSequence* is = GEOSGeom_getCoordSeq(gtmp); - - unsigned int interior_size; - GEOSCoordSeq_getSize(is, &interior_size); - - capacity += interior_size; - } - } - } - - geometry_type* poly = new geometry_type(mapnik::Polygon); - poly->set_capacity (capacity); - - for (unsigned int i = 0; i < num_geometries; ++i) - { - const GEOSGeometry* g = GEOSGetGeometryN(geom, i); - - if (g != NULL && GEOSisValid(g)) - { - const GEOSGeometry* exterior = GEOSGetExteriorRing(g); - const GEOSCoordSequence* es = GEOSGeom_getCoordSeq(exterior); - GEOSCoordSeq_getSize(es, &num_points); - GEOSCoordSeq_getX(es, 0, &x); - GEOSCoordSeq_getY(es, 0, &y); - - num_interior = GEOSGetNumInteriorRings(g); - - poly->move_to (x, y); - for (unsigned int i = 1; i < num_points; ++i) - { - GEOSCoordSeq_getX(es, i, &x); - GEOSCoordSeq_getY(es, i, &y); - - poly->line_to (x, y); - } - for (unsigned int r = 0; r < num_interior; ++r) - { - const GEOSGeometry* gtmp = GEOSGetInteriorRingN(g, r); - const GEOSCoordSequence* is = GEOSGeom_getCoordSeq(gtmp); - - GEOSCoordSeq_getSize(is, &num_points); - GEOSCoordSeq_getX(is, 0, &x); - GEOSCoordSeq_getY(is, 0, &y); - - poly->move_to(x, y); - for (unsigned int i = 1; i < num_points; ++i) - { - GEOSCoordSeq_getX(is, i, &x); - GEOSCoordSeq_getY(is, i, &y); - - poly->line_to(x, y); - } - } - } - } - - feature->add_geometry (poly); -} - -void geos_converter::convert_multipolygon_2 (const GEOSGeometry* geom, feature_ptr feature) -{ -#ifdef MAPNIK_DEBUG - clog << "convert_multipolygon_2" << endl; -#endif - - unsigned int num_geometries = GEOSGetNumGeometries(geom); - - for (unsigned int i = 0; i < num_geometries; ++i) - { - const GEOSGeometry* g = GEOSGetGeometryN(geom, i); - - if (g != NULL && GEOSisValid(g)) - { - convert_polygon (g, feature); - } - } -} - -void geos_converter::convert_collection (const GEOSGeometry* geom, feature_ptr feature, bool multiple_geometries) -{ -#ifdef MAPNIK_DEBUG - clog << "convert_collection" << endl; -#endif - - unsigned int num_geometries = GEOSGetNumGeometries(geom); - - for (unsigned int i = 0; i < num_geometries; ++i) - { - const GEOSGeometry* g = GEOSGetGeometryN(geom, i); - - if (g != NULL && GEOSisValid(g)) - { - convert_geometry (g, feature, multiple_geometries); - } - } -} - diff --git a/plugins/input/geos/geos_converter.hpp b/plugins/input/geos/geos_converter.hpp deleted file mode 100644 index 7207390c9..000000000 --- a/plugins/input/geos/geos_converter.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/***************************************************************************** - * - * This file is part of Mapnik (c++ mapping toolkit) - * - * Copyright (C) 2010 Artem Pavlenko - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - * - *****************************************************************************/ -//$Id$ - -#ifndef GEOS_CONVERTER_HPP -#define GEOS_CONVERTER_HPP - -// mapnik -#include - -// geos -#include - -class geos_converter -{ - public: - static void convert_geometry (const GEOSGeometry* geom, mapnik::feature_ptr feature, bool multiple_geometries); - static void convert_collection (const GEOSGeometry* geom, mapnik::feature_ptr feature, bool multiple_geometries); - static void convert_point (const GEOSGeometry* geom, mapnik::feature_ptr feature); - static void convert_linestring (const GEOSGeometry* geom, mapnik::feature_ptr feature); - static void convert_polygon (const GEOSGeometry* geom, mapnik::feature_ptr feature); - static void convert_multipoint (const GEOSGeometry* geom, mapnik::feature_ptr feature); - static void convert_multipoint_2 (const GEOSGeometry* geom, mapnik::feature_ptr feature); - static void convert_multilinestring (const GEOSGeometry* geom, mapnik::feature_ptr feature); - static void convert_multilinestring_2 (const GEOSGeometry* geom, mapnik::feature_ptr feature); - static void convert_multipolygon (const GEOSGeometry* geom, mapnik::feature_ptr feature); - static void convert_multipolygon_2 (const GEOSGeometry* geom, mapnik::feature_ptr feature); -}; - -#endif // GEOS_FEATURESET_HPP diff --git a/plugins/input/geos/geos_datasource.cpp b/plugins/input/geos/geos_datasource.cpp index 0675fb946..67454b752 100644 --- a/plugins/input/geos/geos_datasource.cpp +++ b/plugins/input/geos/geos_datasource.cpp @@ -65,10 +65,10 @@ using mapnik::filter_in_box; using mapnik::filter_at_point; -void notice(const char* fmt, ...) +void geos_notice(const char* fmt, ...) { va_list ap; - fprintf( stdout, "NOTICE: "); + fprintf( stdout, "GEOS Plugin: (GEOS NOTICE) "); va_start (ap, fmt); vfprintf( stdout, fmt, ap); @@ -76,10 +76,10 @@ void notice(const char* fmt, ...) fprintf( stdout, "\n" ); } -void log_and_exit(const char* fmt, ...) +void geos_error(const char* fmt, ...) { va_list ap; - fprintf( stdout, "ERROR: "); + fprintf( stdout, "GEOS Plugin: (GEOS ERROR) "); va_start (ap, fmt); vfprintf( stdout, fmt, ap); @@ -114,7 +114,7 @@ geos_datasource::geos_datasource(parameters const& params, bool bind) if (gdata) geometry_data_ = *gdata; boost::optional gdata_name = params_.get("field_name"); - if (gdata) geometry_data_name_ = *gdata_name; + if (gdata_name) geometry_data_name_ = *gdata_name; desc_.add_descriptor(attribute_descriptor(geometry_data_name_, mapnik::String)); @@ -130,15 +130,7 @@ geos_datasource::~geos_datasource() { geometry_.set_feature(0); -#ifdef MAPNIK_DEBUG - clog << "finalizing GEOS..."; -#endif - finishGEOS(); - -#ifdef MAPNIK_DEBUG - clog << " finalized !" << endl; -#endif } } @@ -146,86 +138,88 @@ void geos_datasource::bind() const { if (is_bound_) return; -#ifdef MAPNIK_DEBUG - clog << "initializing GEOS..."; -#endif - - // open ogr driver - initGEOS(notice, log_and_exit); - -#ifdef MAPNIK_DEBUG - clog << " initialized !" << endl; -#endif + // open geos driver + initGEOS(geos_notice, geos_error); // parse the string into geometry geometry_.set_feature(GEOSGeomFromWKT(geometry_string_.c_str())); - if (*geometry_ == NULL || ! GEOSisValid(*geometry_)) { - throw datasource_exception("invalid geometry specified"); + throw datasource_exception("GEOS Plugin: invalid geometry specified"); } -#ifdef MAPNIK_DEBUG - clog << "geometry correctly parsed" << endl; -#endif - // try to obtain the extent from the geometry itself if (! extent_initialized_) { #ifdef MAPNIK_DEBUG - clog << "initializing extent from geometry" << endl; + clog << "GEOS Plugin: initializing extent from geometry" << endl; #endif - geos_feature_ptr envelope (GEOSEnvelope(*geometry_)); - - if (*envelope != NULL && GEOSisValid(*envelope)) + if (GEOSGeomTypeId(*geometry_) == GEOS_POINT) { -#ifdef MAPNIK_DEBUG - char* wkt = GEOSGeomToWKT(*envelope); - clog << "getting coord sequence from: " << wkt << endl; - GEOSFree(wkt); -#endif + double x, y; + unsigned int size; - const GEOSGeometry* exterior = GEOSGetExteriorRing(*envelope); - - if (exterior != NULL && GEOSisValid(exterior)) + const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq(*geometry_); + + GEOSCoordSeq_getSize(cs, &size); + GEOSCoordSeq_getX(cs, 0, &x); + GEOSCoordSeq_getY(cs, 0, &y); + + extent_.init(x,y,x,y); + extent_initialized_ = true; + } + else + { + geos_feature_ptr envelope (GEOSEnvelope(*geometry_)); + if (*envelope != NULL && GEOSisValid(*envelope)) { - const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq(exterior); - if (cs != NULL) - { #ifdef MAPNIK_DEBUG - clog << "iterating boundary points" << endl; + char* wkt = GEOSGeomToWKT(*envelope); + clog << "GEOS Plugin: getting coord sequence from: " << wkt << endl; + GEOSFree(wkt); #endif - double x, y; - double minx = std::numeric_limits::max(), - miny = std::numeric_limits::max(), - maxx = -std::numeric_limits::max(), - maxy = -std::numeric_limits::max(); - unsigned int num_points; - - GEOSCoordSeq_getSize(cs, &num_points); - - for (unsigned int i = 0; i < num_points; ++i) + const GEOSGeometry* exterior = GEOSGetExteriorRing(*envelope); + if (exterior != NULL && GEOSisValid(exterior)) + { + const GEOSCoordSequence* cs = GEOSGeom_getCoordSeq(exterior); + if (cs != NULL) { - GEOSCoordSeq_getX(cs, i, &x); - GEOSCoordSeq_getY(cs, i, &y); - - if (x < minx) minx = x; - if (x > maxx) maxx = x; - if (y < miny) miny = y; - if (y > maxy) maxy = y; - } +#ifdef MAPNIK_DEBUG + clog << "GEOS Plugin: iterating boundary points" << endl; +#endif - extent_.init(minx,miny,maxx,maxy); - extent_initialized_ = true; + double x, y; + double minx = std::numeric_limits::max(), + miny = std::numeric_limits::max(), + maxx = -std::numeric_limits::max(), + maxy = -std::numeric_limits::max(); + unsigned int num_points; + + GEOSCoordSeq_getSize(cs, &num_points); + + for (unsigned int i = 0; i < num_points; ++i) + { + GEOSCoordSeq_getX(cs, i, &x); + GEOSCoordSeq_getY(cs, i, &y); + + if (x < minx) minx = x; + if (x > maxx) maxx = x; + if (y < miny) miny = y; + if (y > maxy) maxy = y; + } + + extent_.init(minx,miny,maxx,maxy); + extent_initialized_ = true; + } } } } } if (! extent_initialized_) - throw datasource_exception("cannot determine extent for geometry"); + throw datasource_exception("GEOS Plugin: cannot determine extent for geometry"); is_bound_ = true; } @@ -270,7 +264,7 @@ featureset_ptr geos_datasource::features(query const& q) const << "))"; #ifdef MAPNIK_DEBUG - clog << "using extent: " << s.str() << endl; + clog << "GEOS Plugin: using extent: " << s.str() << endl; #endif return featureset_ptr(new geos_featureset (*geometry_, @@ -290,7 +284,7 @@ featureset_ptr geos_datasource::features_at_point(coord2d const& pt) const s << "POINT(" << pt.x << " " << pt.y << ")"; #ifdef MAPNIK_DEBUG - clog << "using point: " << s.str() << endl; + clog << "GEOS Plugin: using point: " << s.str() << endl; #endif return featureset_ptr(new geos_featureset (*geometry_, diff --git a/plugins/input/geos/geos_feature_ptr.hpp b/plugins/input/geos/geos_feature_ptr.hpp index 42d9e9976..377436f3c 100644 --- a/plugins/input/geos/geos_feature_ptr.hpp +++ b/plugins/input/geos/geos_feature_ptr.hpp @@ -26,7 +26,7 @@ // geos #include - + class geos_feature_ptr { public: @@ -63,5 +63,43 @@ private: GEOSGeometry* feat_; }; + +class geos_wkb_ptr +{ +public: + geos_wkb_ptr (GEOSGeometry* const geometry) + : data_ (NULL), + size_ (0) + { + data_ = GEOSGeomToWKB_buf(geometry, &size_); + } + + ~geos_wkb_ptr () + { + if (data_ != NULL) + GEOSFree(data_); + } + + bool is_valid() const + { + return (data_ != NULL) && (size_ > 0); + } + + unsigned int size() const + { + return (unsigned int) size_; + } + + const char* data() + { + return reinterpret_cast(data_); + } + +private: + unsigned char* data_; + size_t size_; +}; + + #endif // GEOS_FEATURE_PTR_HPP diff --git a/plugins/input/geos/geos_featureset.cpp b/plugins/input/geos/geos_featureset.cpp index 141440c67..cc1abd4fb 100644 --- a/plugins/input/geos/geos_featureset.cpp +++ b/plugins/input/geos/geos_featureset.cpp @@ -36,7 +36,6 @@ // ogr #include "geos_featureset.hpp" -#include "geos_converter.hpp" using std::clog; using std::endl; @@ -106,7 +105,7 @@ feature_ptr geos_featureset::next() break; default: #ifdef MAPNIK_DEBUG - clog << "unknown extent geometry_type=" << type << endl; + clog << "GEOS Plugin: unknown extent geometry_type=" << type << endl; #endif break; } @@ -114,16 +113,23 @@ feature_ptr geos_featureset::next() if (render_geometry) { - feature_ptr feature(new Feature(identifier_)); - - geos_converter::convert_geometry (geometry_, feature, multiple_geometries_); - - if (field_ != "") + geos_wkb_ptr wkb(geometry_); + if (wkb.is_valid()) { - boost::put(*feature, field_name_, tr_->transcode(field_.c_str())); + feature_ptr feature(new Feature(identifier_)); + + geometry_utils::from_wkb(*feature, + wkb.data(), + wkb.size(), + multiple_geometries_); + + if (field_ != "") + { + boost::put(*feature, field_name_, tr_->transcode(field_.c_str())); + } + + return feature; } - - return feature; } } }