File: GeosOp.h

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 (88 lines) | stat: -rw-r--r-- 2,324 bytes parent folder | download
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/**********************************************************************
 *
 * GEOS - Geometry Engine Open Source
 * http://geos.osgeo.org
 *
 * Copyright (C) 2020 Martin Davis
 *
 * 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.
 *
 **********************************************************************/

#pragma once

#include <geos/geom/GeometryFactory.h>
#include <geos/geom/PrecisionModel.h>

using namespace geos;
using namespace geos::geom;


class GeosOpArgs {

public:
    enum {
        fmtNone, fmtText, fmtWKB
    } format = fmtNone;

    bool isShowTime = false;
    bool isVerbose = false;
    int precision = -1;
    int repeatNum = 1;

    //std::string format;

    std::string srcA;
    int limitA = -1;
    bool isCollect = true;
    bool isExplode = false;

    std::string srcB;

    std::string opName;
    double opArg1 = 0.0;
    //std::string opArg2;
};

class GeosOp {

public:
    static std::string const opNames[];

    GeosOp(GeosOpArgs& args);
    ~GeosOp();
    void run();

private:

    GeosOpArgs& args;

    long opCount = 0;
    std::size_t vertexCount = 0;
    double totalTime = 0;

    std::vector<std::unique_ptr<Geometry>> geomA;

    std::vector<std::unique_ptr<Geometry>> geomB;

    std::vector<std::unique_ptr<Geometry>> readInput(std::string name, std::string src, int limit);
    std::vector<std::unique_ptr<Geometry>> loadInput(std::string name, std::string src, int limit);
    void execute();
    void executeUnary(GeomFunction * fun);
    void executeBinary(GeomFunction * fun);
    Result* executeOpRepeat(GeomFunction * fun,
        unsigned int indexA, const  std::unique_ptr<Geometry>& geomA,
        unsigned int indexB, const  std::unique_ptr<Geometry>& geomB);
    Result* executeOp(GeomFunction * fun,
        unsigned int indexA, const  std::unique_ptr<Geometry>& geomA,
        unsigned int indexB, const  std::unique_ptr<Geometry>& geomB);
    void output(Result* result);
    void outputExplode(std::unique_ptr<Geometry>& geom);
    void outputGeometry( const Geometry* geom);
    void outputGeometryList(std::vector<std::unique_ptr<const Geometry>> & val);
    void log(std::string s);
};