File: IndexedPointInAreaLocatorTest.cpp

package info (click to toggle)
geos 3.14.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 31,212 kB
  • sloc: cpp: 199,103; xml: 56,065; ansic: 6,162; sh: 287; makefile: 26
file content (87 lines) | stat: -rw-r--r-- 2,753 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
#include <tut/tut.hpp>
// geos
#include <geos/geom/CoordinateSequence.h>
#include <geos/geom/GeometryFactory.h>
#include <geos/algorithm/locate/IndexedPointInAreaLocator.h>

// std
#include <memory>

using geos::geom::CoordinateXY;
using geos::geom::CoordinateSequence;
using geos::geom::GeometryFactory;
using geos::geom::Location;
using geos::algorithm::locate::IndexedPointInAreaLocator;

namespace tut {
//
// Test Group
//

// dummy data, not used
struct test_indexedpointinarealocator_data {
    const GeometryFactory& factory_ = *GeometryFactory::getDefaultInstance();
};

typedef test_group<test_indexedpointinarealocator_data> group;
typedef group::object object;

group test_indexedpointinarealocator_group("geos::algorithm::locate::IndexedPointInAreaLocator");

// Test all CoordinateSequence dimensions
template<>
template<>
void object::test<1>
()
{
    // XY
    CoordinateSequence seq_xy = CoordinateSequence::XY(0);
    seq_xy.add(0.0, 0.0);
    seq_xy.add(1.0, 0.0);
    seq_xy.add(1.0, 1.0);
    seq_xy.add(0.0, 1.0);
    seq_xy.add(0.0, 0.0);
    auto ls_xy = factory_.createLineString(seq_xy.clone());
    IndexedPointInAreaLocator ipa_xy(*ls_xy);

    CoordinateXY pt_boundary(0.5, 0);
    CoordinateXY pt_interior(0.5, 0.5);
    CoordinateXY pt_exterior(1.5, 0.5);

    ensure_equals(ipa_xy.locate(&pt_boundary), Location::BOUNDARY);
    ensure_equals(ipa_xy.locate(&pt_interior), Location::INTERIOR);
    ensure_equals(ipa_xy.locate(&pt_exterior), Location::EXTERIOR);

    // XYZ
    CoordinateSequence seq_xyz = CoordinateSequence::XYZ(0);
    seq_xyz.add(seq_xy);
    auto ls_xyz = factory_.createLineString(seq_xyz.clone());

    IndexedPointInAreaLocator ipa_xyz(*ls_xy);
    ensure_equals(ipa_xyz.locate(&pt_boundary), Location::BOUNDARY);
    ensure_equals(ipa_xyz.locate(&pt_interior), Location::INTERIOR);
    ensure_equals(ipa_xyz.locate(&pt_exterior), Location::EXTERIOR);

    // XYM
    CoordinateSequence seq_xym = CoordinateSequence::XYM(0);
    seq_xym.add(seq_xy);
    auto ls_xym = factory_.createLineString(seq_xym.clone());

    IndexedPointInAreaLocator ipa_xym(*ls_xy);
    ensure_equals(ipa_xym.locate(&pt_boundary), Location::BOUNDARY);
    ensure_equals(ipa_xym.locate(&pt_interior), Location::INTERIOR);
    ensure_equals(ipa_xym.locate(&pt_exterior), Location::EXTERIOR);

    // XYZM
    CoordinateSequence seq_xyzm = CoordinateSequence::XYZM(0);
    seq_xyzm.add(seq_xy);
    auto ls_xyzm = factory_.createLineString(seq_xyzm.clone());

    IndexedPointInAreaLocator ipa_xyzm(*ls_xy);
    ensure_equals(ipa_xyzm.locate(&pt_boundary), Location::BOUNDARY);
    ensure_equals(ipa_xyzm.locate(&pt_interior), Location::INTERIOR);
    ensure_equals(ipa_xyzm.locate(&pt_exterior), Location::EXTERIOR);
}

}