Opened 10 years ago
Closed 6 years ago
#685 closed defect (wontfix)
WKT unreadable text (WKTWriter)
Reported by: | tpgalan | Owned by: | strk |
---|---|---|---|
Priority: | major | Milestone: | 3.6.3 |
Component: | C API | Version: | 3.4.2 |
Severity: | Unassigned | Keywords: | WKTWriter WKT |
Cc: |
Description
Hi there:
I've tried to see how it is working WKTWriter C++ class with some code inspired in http://svn.osgeo.org/geos/trunk/doc/example.cpp.
The thing is that when I want to print the WKT string generated from a simple geometry (in this case, a point) it fails printing unreadable characters.
Could you please help me to solve this issue? Here is the code.
#include <geos/geom/PrecisionModel.h> #include <geos/geom/GeometryFactory.h> #include <geos/geom/Geometry.h> #include <geos/geom/Point.h> #include <geos/geom/LinearRing.h> #include <geos/geom/LineString.h> #include <geos/geom/Polygon.h> #include <geos/geom/GeometryCollection.h> #include <geos/geom/Coordinate.h> #include <geos/geom/CoordinateSequence.h> #include <geos/geom/CoordinateArraySequence.h> #include <geos/geom/IntersectionMatrix.h> #include <geos/io/WKBReader.h> #include <geos/io/WKBWriter.h> #include <geos/io/WKTWriter.h> #include <geos/util/GeometricShapeFactory.h> #include <geos/geom/util/SineStarFactory.h> #include <geos/util/GEOSException.h> #include <geos/util/IllegalArgumentException.h> #include <geos/opLinemerge.h> #include <geos/opPolygonize.h> #include <vector> #include <sstream> #include <iomanip> #include <cstdlib> exit()
using namespace std; using namespace geos; using namespace geos::geom; using namespace geos::operation::polygonize; using namespace geos::operation::linemerge; using geos::util::GEOSException; using geos::util::IllegalArgumentException;
GeometryFactory *global_factory;
This is the simpler geometry you can get: a point. Point * create_point(double x, double y) {
Coordinate c(x, y); Point *p = global_factory->createPoint(c); return p;
}
This function will print given geometries in WKT format to stdout. As a side-effect, will test WKB output and input, using the WKBtest function. void wkt_print_geoms(vector<Geometry *> *geoms) {
WKT-print given geometries io::WKTWriter *wkt = new io::WKTWriter(); for (unsigned int i=0; i<geoms->size(); i++) {
const Geometry *g = (*geoms)[i]; string tmp=wkt->write(g); cout<<"<<i<< (WKT) "<<tmp<<endl;
} delete wkt;
}
void do_all() {
vector<Geometry *> *geoms = new vector<Geometry *>; vector<Geometry *> *newgeoms;
Define a precision model using 0,0 as the reference origin and 2.0 as coordinates scale. PrecisionModel *pm = new PrecisionModel(2.0, 0, 0);
Initialize global factory with defined PrecisionModel and a SRID of -1 (undefined). global_factory = new GeometryFactory(pm, -1);
We do not need PrecisionMode object anymore, it has been copied to global_factory private storage delete pm;
GEOMETRY CREATION
Read function bodies to see the magic behind them geoms->push_back(create_point(150, 350));
cout<<"--------HERE ARE THE BASE GEOMS ----------"<<endl;
wkt_print_geoms(geoms);
}
int main(){
do_all(); getchar();
}
Thanks.
Change History (4)
comment:1 by , 8 years ago
Milestone: | 3.4.3 → 3.6.1 |
---|
comment:4 by , 6 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Too old to care. May not even be an issue anymore.
Ticket retargeted after milestone deleted