File Coverage

xsi/GeometryFactory.xsi
Criterion Covered Total %
statement 64 67 95.5
branch 86 164 52.4
condition n/a
subroutine n/a
pod n/a
total 150 231 64.9


line stmt bran cond sub pod time code
1             MODULE = Geo::Geos PACKAGE = Geo::Geos::GeometryFactory
2             PROTOTYPES: DISABLE
3              
4             GeometryFactory* create(SV* arg1 = NULL, SV* arg2 = NULL) {
5 62           GeometryFactory::Ptr ptr;
6 31           if (!arg1) {
7 31 100         ptr = GeometryFactory::create();
8 27 50         }
9             else {
10             auto& pm = xs::in(arg1);
11 4 50         if (arg2) {
12 4 100         int srid = SvIV(arg2);
13 3 50         ptr = GeometryFactory::create(&pm, srid);
    0          
14 3 50         }
15             else ptr = GeometryFactory::create(&pm);
16 1 50         }
17              
18             if (ptr.get()) {
19 31 50         /* steal pointer without destroying the factory */
20             RETVAL = ptr.release();
21 31           }
22             else throw ("unsupported arguments");
23 0           }
24              
25             PrecisionModel* GeometryFactory::getPrecisionModel() {
26 2           auto pm = THIS->getPrecisionModel();
27 1 50         RETVAL = new PrecisionModel(*pm);
28 1 50         }
    50          
29              
30 4 50         int GeometryFactory::getSRID ()
31              
32             GeometryCollection* GeometryFactory::createGeometryCollection() {
33 2           RETVAL = THIS->createGeometryCollection();
34 1 50         }
35              
36             Point* GeometryFactory::createPoint(Sv arg1 = Sv{}, SV* arg2 = NULL) {
37 70           if (!arg1) RETVAL = THIS->createPoint();
38 35 100         else {
    50          
39             if (!arg1.is_array_ref()) {
40 34 50         Object obj {arg1};
    100          
41 64 50         if (obj && obj.stash().name() == "Geo::Geos::Coordinate") {
42 32 50         auto coord = xs::in(obj);
    50          
    50          
    50          
    50          
    50          
    0          
43 32 50         RETVAL = THIS->createPoint(*coord);
44 32 50         }
45             else throw ("Object must be blessed into Geo::Geos::Coordinate");
46 0           }
47             else {
48             if (!arg2) throw ("missing mandatory argument");
49 2 50         size_t dims = SvIV(arg2);
50 2 50         auto seq = Helper::convert_copy(*THIS, Array(arg1), dims);
    0          
51 2 50         RETVAL = THIS->createPoint(seq);
    50          
52 2 50         }
53             }
54             }
55              
56             MultiPoint* GeometryFactory::createMultiPoint(SV* arg1 = NULL, SV* arg2 = NULL) {
57 26           if (!arg1) RETVAL = THIS->createMultiPoint();
58 13 100         else {
    50          
59             if (!arg2) throw ("missing mandatory argument");
60 11 50         size_t dims = SvIV(arg2);
61 11 50         auto seq = std::unique_ptr(Helper::convert_copy(*THIS, Array(arg1), dims));
    0          
62 22 50         RETVAL = THIS->createMultiPoint(*seq);
    50          
63 11 50         }
64             }
65              
66             LineString* GeometryFactory::createLineString(SV* arg1 = NULL, SV* arg2 = NULL) {
67 44           if (!arg1) RETVAL = THIS->createLineString();
68 22 100         else {
    50          
69             if (!arg2) throw ("missing argument");
70 21 50         size_t dims = SvIV(arg2);
71 21 50         auto seq = std::unique_ptr(Helper::convert_copy(*THIS, Array(arg1), dims));
    0          
72 42 50         RETVAL = THIS->createLineString(*seq);
    50          
73 21 50         }
74             }
75              
76             MultiLineString* GeometryFactory::createMultiLineString(SV* arg1 = NULL) {
77 6           if (!arg1) RETVAL = THIS->createMultiLineString();
78 3 100         else {
    50          
79             Array geometries(arg1);
80 4 50         if (!geometries) throw ("unsupported argument");
81 2 50         auto lines = Helper::convert_geometries(geometries);
82 4 50         RETVAL = THIS->createMultiLineString(lines);
    50          
83 2 50         }
84             }
85              
86             LinearRing* GeometryFactory::createLinearRing(SV* arg1 = NULL, SV* arg2 = NULL) {
87 44           if (!arg1) RETVAL = THIS->createLinearRing();
88 22 100         else {
    50          
89             if (!arg2) throw ("missing argument");
90 21 50         size_t dims = SvIV(arg2);
91 21 50         auto seq = std::unique_ptr(Helper::convert_copy(*THIS, Array(arg1), dims));
    0          
92 42 50         RETVAL = THIS->createLinearRing(*seq);
    50          
93 21 50         }
94             }
95              
96             geos::geom::Polygon* GeometryFactory::createPolygon(SV* arg1 = NULL, SV* arg2 = NULL) {
97 32           if (!arg1) RETVAL = THIS->createPolygon();
98 16 100         else {
    50          
99             auto ring = xs::in(arg1);
100 15 50         auto holes = Helper::convert_geometries(Array(arg2));
101 30 50         RETVAL = THIS->createPolygon(*ring, holes);
    50          
102 15 50         }
103             }
104              
105             MultiPolygon* GeometryFactory::createMultiPolygon(SV* arg1 = NULL) {
106 4           if (!arg1) RETVAL = THIS->createMultiPolygon();
107 2 100         else {
    50          
108             auto polygons = Helper::convert_geometries(Array(arg1));
109 2 50         RETVAL = THIS->createMultiPolygon(polygons);
    50          
110 1 50         }
111             }
112              
113             Sv GeometryFactory::toGeometry(Envelope* env) {
114 1 50         RETVAL = Helper::uplift(THIS->toGeometry(env));
    50          
115             }
116              
117             Sv GeometryFactory::createEmptyGeometry() {
118 1 50         RETVAL = Helper::uplift(THIS->createEmptyGeometry());
    50          
119             }
120              
121 0           int CLONE_SKIP (...) { PERL_UNUSED_VAR(items); RETVAL = 1; }
122              
123             BOOT {
124 46 50         xs::exp::autoexport(Stash(__PACKAGE__));
    50          
125             }