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 {
33 {
34 return CppProxy.distanceBetweenGlobalPoints(from,
35 to);
36 }
37
53 public static float distanceBetweenPoints(Point from, Point to)
54 {
55 return CppProxy.distanceBetweenPoints(from,
56 to);
57 }
58
73 public static float segmentLength(Segment segment)
74 {
75 return CppProxy.segmentLength(segment);
76 }
77
92 public static float polygonArea(Polygon polygon)
93 {
94 return CppProxy.polygonArea(polygon);
95 }
96
111 public static Point polygonCenter(Polygon polygon)
112 {
113 return CppProxy.polygonCenter(polygon);
114 }
115
131 public static boolean polygonContainsPoint(Polygon polygon, Point point)
132 {
133 return CppProxy.polygonContainsPoint(polygon,
134 point);
135 }
136
152 public static float segmentPointDistance(Segment segment, Point point)
153 {
154 return CppProxy.segmentPointDistance(segment,
155 point);
156 }
157
173 public static boolean segmentIntersectsSegment(Segment segment1, Segment segment2)
174 {
175 return CppProxy.segmentIntersectsSegment(segment1,
176 segment2);
177 }
178
194 public static Point segmentIntersectionSegment(Segment segment1, Segment segment2)
195 {
196 return CppProxy.segmentIntersectionSegment(segment1,
197 segment2);
198 }
199
215 public static float divisionRatioBySegment(Segment segment1, Segment segment2)
216 {
217 return CppProxy.divisionRatioBySegment(segment1,
218 segment2);
219 }
220
236 public static Point getRatioPoint(Segment segment, double r)
237 {
238 return CppProxy.getRatioPoint(segment,
239 r);
240 }
241
258 public static double getProjectionRatio(Segment segment, Point point)
259 {
260 return CppProxy.getProjectionRatio(segment,
261 point);
262 }
263
264 private static final class CppProxy extends GeometryUtils
265 {
266 private final long nativeRef;
267 private final AtomicBoolean destroyed = new AtomicBoolean(false);
268
269 private CppProxy(long nativeRef)
270 {
271 if (nativeRef == 0) throw new RuntimeException("nativeRef is zero");
272 this.nativeRef = nativeRef;
273 }
274
275 private native void nativeDestroy(long nativeRef);
276 public void _djinni_private_destroy()
277 {
278 boolean destroyed = this.destroyed.getAndSet(true);
279 if (!destroyed) nativeDestroy(this.nativeRef);
280 }
281 protected void finalize() throws java.lang.Throwable
282 {
283 _djinni_private_destroy();
284 super.finalize();
285 }
286
287 // GeometryUtils methods
288
289 public static native float distanceBetweenGlobalPoints(GlobalPoint from, GlobalPoint to);
290
291 public static native float distanceBetweenPoints(Point from, Point to);
292
293 public static native float segmentLength(Segment segment);
294
295 public static native float polygonArea(Polygon polygon);
296
297 public static native Point polygonCenter(Polygon polygon);
298
299 public static native boolean polygonContainsPoint(Polygon polygon, Point point);
300
301 public static native float segmentPointDistance(Segment segment, Point point);
302
303 public static native boolean segmentIntersectsSegment(Segment segment1, Segment segment2);
304
305 public static native Point segmentIntersectionSegment(Segment segment1, Segment segment2);
306
307 public static native float divisionRatioBySegment(Segment segment1, Segment segment2);
308
309 public static native Point getRatioPoint(Segment segment, double r);
310
311 public static native double getProjectionRatio(Segment segment, Point point);
312 }
313}