File: SimpleWKTTester.cpp

package info (click to toggle)
geos 3.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 28,996 kB
  • sloc: cpp: 157,310; xml: 53,816; ansic: 6,956; sh: 302; makefile: 30
file content (71 lines) | stat: -rw-r--r-- 1,891 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.osgeo.org
 *
 * Copyright (C) 2006 Refractions Research Inc.
 * Copyright (C) 2001-2002 Vivid Solutions Inc.
 *
 * This is free software; you can redistribute and/or modify it under
 * the terms of the GNU Lesser General Public Licence as published
 * by the Free Software Foundation.
 * See the COPYING file for more information.
 *
 **********************************************************************/


#include <iostream>
#include <fstream>

#include <geos/io/WKTWriter.h>
#include <geos/io/WKTReader.h>
#include <geos/geom/PrecisionModel.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/geom/Geometry.h>
#include <geos/util/GEOSException.h>

using namespace std;
using namespace geos::io;
using namespace geos::geom;
using namespace geos::util;

int
main(int /*argc*/, char** /*argv*/)
{

    try {
        ofstream out("WKTOut");
        ifstream in("WKTIn");
        string instr;
        string outstr;
        PrecisionModel pm;
        GeometryFactory::Ptr gf = GeometryFactory::create(&pm, 10);
        WKTReader* r = new WKTReader(gf.get());
        WKTWriter* w = new WKTWriter();
        Geometry* g;

        cout << "Start Testing:" << endl;
        while(!in.eof()) {
            getline(in, instr);
            if(instr != "") {
                g = r->read(instr).release();
                outstr = w->write(g);
                out << "----------" << endl;
                out << instr << endl;
                out << outstr << endl;
                out << "----------" << endl << endl;
            }
        }
        out.flush();
        out.close();
        cout << "End of Testing" << endl;
        delete r;
        delete w;

    }
    catch(const GEOSException& ge) {
        cout << ge.what() << endl;
    }

    return 0;
}