Loading...
Searching...
No Matches
GeometryUtils.java
Go to the documentation of this file.
1package com.navigine.idl.java;
2
3import java.util.concurrent.atomic.AtomicBoolean;
4
16public abstract class GeometryUtils {
24 {
25 return CppProxy.distanceBetweenGlobalPoints(from,
26 to);
27 }
28
35 public static float distanceBetweenPoints(Point from, Point to)
36 {
37 return CppProxy.distanceBetweenPoints(from,
38 to);
39 }
40
46 public static float segmentLength(Segment segment)
47 {
48 return CppProxy.segmentLength(segment);
49 }
50
56 public static float polygonArea(Polygon polygon)
57 {
58 return CppProxy.polygonArea(polygon);
59 }
60
66 public static Point polygonCenter(Polygon polygon)
67 {
68 return CppProxy.polygonCenter(polygon);
69 }
70
77 public static boolean polygonContainsPoint(Polygon polygon, Point point)
78 {
79 return CppProxy.polygonContainsPoint(polygon,
80 point);
81 }
82
89 public static float segmentPointDistance(Segment segment, Point point)
90 {
91 return CppProxy.segmentPointDistance(segment,
92 point);
93 }
94
101 public static boolean segmentIntersectsSegment(Segment segment1, Segment segment2)
102 {
103 return CppProxy.segmentIntersectsSegment(segment1,
104 segment2);
105 }
106
113 public static Point segmentIntersectionSegment(Segment segment1, Segment segment2)
114 {
115 return CppProxy.segmentIntersectionSegment(segment1,
116 segment2);
117 }
118
125 public static float divisionRatioBySegment(Segment segment1, Segment segment2)
126 {
127 return CppProxy.divisionRatioBySegment(segment1,
128 segment2);
129 }
130
137 public static Point getRatioPoint(Segment segment, double r)
138 {
139 return CppProxy.getRatioPoint(segment,
140 r);
141 }
142
150 public static double getProjectionRatio(Segment segment, Point point)
151 {
152 return CppProxy.getProjectionRatio(segment,
153 point);
154 }
155
156 private static final class CppProxy extends GeometryUtils
157 {
158 private final long nativeRef;
159 private final AtomicBoolean destroyed = new AtomicBoolean(false);
160
161 private CppProxy(long nativeRef)
162 {
163 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
164 this.nativeRef = nativeRef;
165 }
166
167 private native void nativeDestroy(long nativeRef);
168 public void _djinni_private_destroy()
169 {
170 boolean destroyed = this.destroyed.getAndSet(true);
171 if (!destroyed) nativeDestroy(this.nativeRef);
172 }
173 protected void finalize() throws java.lang.Throwable
174 {
175 _djinni_private_destroy();
176 super.finalize();
177 }
178
179 // GeometryUtils methods
180
181 public static native float distanceBetweenGlobalPoints(GlobalPoint from, GlobalPoint to);
182
183 public static native float distanceBetweenPoints(Point from, Point to);
184
185 public static native float segmentLength(Segment segment);
186
187 public static native float polygonArea(Polygon polygon);
188
189 public static native Point polygonCenter(Polygon polygon);
190
191 public static native boolean polygonContainsPoint(Polygon polygon, Point point);
192
193 public static native float segmentPointDistance(Segment segment, Point point);
194
195 public static native boolean segmentIntersectsSegment(Segment segment1, Segment segment2);
196
197 public static native Point segmentIntersectionSegment(Segment segment1, Segment segment2);
198
199 public static native float divisionRatioBySegment(Segment segment1, Segment segment2);
200
201 public static native Point getRatioPoint(Segment segment, double r);
202
203 public static native double getProjectionRatio(Segment segment, Point point);
204 }
205}