source: josm/trunk/src/org/openstreetmap/josm/gui/MapViewState.java@ 12288

Last change on this file since 12288 was 12213, checked in by michael2402, 7 years ago

See #13415: Make code shorter by using LatLon.getEastNorth()

  • Property svn:eol-style set to native
File size: 25.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui;
3
4import java.awt.Container;
5import java.awt.Point;
6import java.awt.geom.AffineTransform;
7import java.awt.geom.Area;
8import java.awt.geom.Path2D;
9import java.awt.geom.Point2D;
10import java.awt.geom.Point2D.Double;
11import java.awt.geom.Rectangle2D;
12import java.io.Serializable;
13import java.util.Objects;
14import java.util.Optional;
15
16import javax.swing.JComponent;
17
18import org.openstreetmap.josm.Main;
19import org.openstreetmap.josm.data.Bounds;
20import org.openstreetmap.josm.data.ProjectionBounds;
21import org.openstreetmap.josm.data.coor.EastNorth;
22import org.openstreetmap.josm.data.coor.ILatLon;
23import org.openstreetmap.josm.data.coor.LatLon;
24import org.openstreetmap.josm.data.osm.Node;
25import org.openstreetmap.josm.data.projection.Projecting;
26import org.openstreetmap.josm.data.projection.Projection;
27import org.openstreetmap.josm.gui.download.DownloadDialog;
28import org.openstreetmap.josm.tools.CheckParameterUtil;
29import org.openstreetmap.josm.tools.Geometry;
30import org.openstreetmap.josm.tools.JosmRuntimeException;
31import org.openstreetmap.josm.tools.bugreport.BugReport;
32
33/**
34 * This class represents a state of the {@link MapView}.
35 * @author Michael Zangl
36 * @since 10343
37 */
38public final class MapViewState implements Serializable {
39
40 private static final long serialVersionUID = 1L;
41
42 /**
43 * A flag indicating that the point is outside to the top of the map view.
44 * @since 10827
45 */
46 public static final int OUTSIDE_TOP = 1;
47
48 /**
49 * A flag indicating that the point is outside to the bottom of the map view.
50 * @since 10827
51 */
52 public static final int OUTSIDE_BOTTOM = 2;
53
54 /**
55 * A flag indicating that the point is outside to the left of the map view.
56 * @since 10827
57 */
58 public static final int OUTSIDE_LEFT = 4;
59
60 /**
61 * A flag indicating that the point is outside to the right of the map view.
62 * @since 10827
63 */
64 public static final int OUTSIDE_RIGHT = 8;
65
66 /**
67 * Additional pixels outside the view for where to start clipping.
68 */
69 private static final int CLIP_BOUNDS = 50;
70
71 private final transient Projecting projecting;
72
73 private final int viewWidth;
74 private final int viewHeight;
75
76 private final double scale;
77
78 /**
79 * Top left {@link EastNorth} coordinate of the view.
80 */
81 private final EastNorth topLeft;
82
83 private final Point topLeftOnScreen;
84 private final Point topLeftInWindow;
85
86 /**
87 * Create a new {@link MapViewState}
88 * @param projection The projection to use.
89 * @param viewWidth The view width
90 * @param viewHeight The view height
91 * @param scale The scale to use
92 * @param topLeft The top left corner in east/north space.
93 * @param topLeftInWindow The top left point in window
94 * @param topLeftOnScreen The top left point on screen
95 */
96 private MapViewState(Projecting projection, int viewWidth, int viewHeight, double scale, EastNorth topLeft,
97 Point topLeftInWindow, Point topLeftOnScreen) {
98 CheckParameterUtil.ensureParameterNotNull(projection, "projection");
99 CheckParameterUtil.ensureParameterNotNull(topLeft, "topLeft");
100 CheckParameterUtil.ensureParameterNotNull(topLeftInWindow, "topLeftInWindow");
101 CheckParameterUtil.ensureParameterNotNull(topLeftOnScreen, "topLeftOnScreen");
102
103 this.projecting = projection;
104 this.scale = scale;
105 this.topLeft = topLeft;
106
107 this.viewWidth = viewWidth;
108 this.viewHeight = viewHeight;
109 this.topLeftInWindow = topLeftInWindow;
110 this.topLeftOnScreen = topLeftOnScreen;
111 }
112
113 private MapViewState(Projecting projection, int viewWidth, int viewHeight, double scale, EastNorth topLeft) {
114 this(projection, viewWidth, viewHeight, scale, topLeft, new Point(0, 0), new Point(0, 0));
115 }
116
117 private MapViewState(EastNorth topLeft, MapViewState mvs) {
118 this(mvs.projecting, mvs.viewWidth, mvs.viewHeight, mvs.scale, topLeft, mvs.topLeftInWindow, mvs.topLeftOnScreen);
119 }
120
121 private MapViewState(double scale, MapViewState mvs) {
122 this(mvs.projecting, mvs.viewWidth, mvs.viewHeight, scale, mvs.topLeft, mvs.topLeftInWindow, mvs.topLeftOnScreen);
123 }
124
125 private MapViewState(JComponent position, MapViewState mvs) {
126 this(mvs.projecting, position.getWidth(), position.getHeight(), mvs.scale, mvs.topLeft,
127 findTopLeftInWindow(position), findTopLeftOnScreen(position));
128 }
129
130 private MapViewState(Projecting projecting, MapViewState mvs) {
131 this(projecting, mvs.viewWidth, mvs.viewHeight, mvs.scale, mvs.topLeft, mvs.topLeftInWindow, mvs.topLeftOnScreen);
132 }
133
134 private static Point findTopLeftInWindow(JComponent position) {
135 Point result = new Point();
136 // better than using swing utils, since this allows us to use the method if no screen is present.
137 Container component = position;
138 while (component != null) {
139 result.x += component.getX();
140 result.y += component.getY();
141 component = component.getParent();
142 }
143 return result;
144 }
145
146 private static Point findTopLeftOnScreen(JComponent position) {
147 try {
148 return position.getLocationOnScreen();
149 } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
150 throw BugReport.intercept(e).put("position", position).put("parent", position::getParent);
151 }
152 }
153
154 /**
155 * The scale in east/north units per pixel.
156 * @return The scale.
157 */
158 public double getScale() {
159 return scale;
160 }
161
162 /**
163 * Gets the MapViewPoint representation for a position in view coordinates.
164 * @param x The x coordinate inside the view.
165 * @param y The y coordinate inside the view.
166 * @return The MapViewPoint.
167 */
168 public MapViewPoint getForView(double x, double y) {
169 return new MapViewViewPoint(x, y);
170 }
171
172 /**
173 * Gets the {@link MapViewPoint} for the given {@link EastNorth} coordinate.
174 * @param eastNorth the position.
175 * @return The point for that position.
176 */
177 public MapViewPoint getPointFor(EastNorth eastNorth) {
178 return new MapViewEastNorthPoint(eastNorth);
179 }
180
181 /**
182 * Gets the {@link MapViewPoint} for the given {@link LatLon} coordinate.
183 * <p>
184 * This method exists to not break binary compatibility with old plugins
185 * @param latlon the position
186 * @return The point for that position.
187 * @since 10651
188 */
189 public MapViewPoint getPointFor(LatLon latlon) {
190 return getPointFor((ILatLon) latlon);
191 }
192
193 /**
194 * Gets the {@link MapViewPoint} for the given {@link LatLon} coordinate.
195 * @param latlon the position
196 * @return The point for that position.
197 * @since 12161
198 */
199 public MapViewPoint getPointFor(ILatLon latlon) {
200 try {
201 return getPointFor(Optional.ofNullable(latlon.getEastNorth(getProjection()))
202 .orElseThrow(IllegalArgumentException::new));
203 } catch (JosmRuntimeException | IllegalArgumentException | IllegalStateException e) {
204 throw BugReport.intercept(e).put("latlon", latlon);
205 }
206 }
207
208 /**
209 * Gets the {@link MapViewPoint} for the given node.
210 * This is faster than {@link #getPointFor(LatLon)} because it uses the node east/north cache.
211 * @param node The node
212 * @return The position of that node.
213 * @since 10827
214 */
215 public MapViewPoint getPointFor(Node node) {
216 return getPointFor((ILatLon) node);
217 }
218
219 /**
220 * Gets a rectangle representing the whole view area.
221 * @return The rectangle.
222 */
223 public MapViewRectangle getViewArea() {
224 return getForView(0, 0).rectTo(getForView(viewWidth, viewHeight));
225 }
226
227 /**
228 * Gets a rectangle of the view as map view area.
229 * @param rectangle The rectangle to get.
230 * @return The view area.
231 * @since 10827
232 */
233 public MapViewRectangle getViewArea(Rectangle2D rectangle) {
234 return getForView(rectangle.getMinX(), rectangle.getMinY()).rectTo(getForView(rectangle.getMaxX(), rectangle.getMaxY()));
235 }
236
237 /**
238 * Gets the center of the view.
239 * @return The center position.
240 */
241 public MapViewPoint getCenter() {
242 return getForView(viewWidth / 2.0, viewHeight / 2.0);
243 }
244
245 /**
246 * Gets the width of the view on the Screen;
247 * @return The width of the view component in screen pixel.
248 */
249 public double getViewWidth() {
250 return viewWidth;
251 }
252
253 /**
254 * Gets the height of the view on the Screen;
255 * @return The height of the view component in screen pixel.
256 */
257 public double getViewHeight() {
258 return viewHeight;
259 }
260
261 /**
262 * Gets the current projection used for the MapView.
263 * @return The projection.
264 * @see #getProjecting()
265 */
266 public Projection getProjection() {
267 return projecting.getBaseProjection();
268 }
269
270 /**
271 * Gets the current projecting instance that is used to convert between east/north and lat/lon space.
272 * @return The projection.
273 * @since 12161
274 */
275 public Projecting getProjecting() {
276 return projecting;
277 }
278
279 /**
280 * Creates an affine transform that is used to convert the east/north coordinates to view coordinates.
281 * @return The affine transform. It should not be changed.
282 * @since 10375
283 */
284 public AffineTransform getAffineTransform() {
285 return new AffineTransform(1.0 / scale, 0.0, 0.0, -1.0 / scale, -topLeft.east() / scale,
286 topLeft.north() / scale);
287 }
288
289 /**
290 * Gets a rectangle that is several pixel bigger than the view. It is used to define the view clipping.
291 * @return The rectangle.
292 */
293 public MapViewRectangle getViewClipRectangle() {
294 return getForView(-CLIP_BOUNDS, -CLIP_BOUNDS).rectTo(getForView(getViewWidth() + CLIP_BOUNDS, getViewHeight() + CLIP_BOUNDS));
295 }
296
297 /**
298 * Returns the area for the given bounds.
299 * @param bounds bounds
300 * @return the area for the given bounds
301 */
302 public Area getArea(Bounds bounds) {
303 Path2D area = new Path2D.Double();
304 bounds.visitEdge(getProjection(), latlon -> {
305 MapViewPoint point = getPointFor(latlon);
306 if (area.getCurrentPoint() == null) {
307 area.moveTo(point.getInViewX(), point.getInViewY());
308 } else {
309 area.lineTo(point.getInViewX(), point.getInViewY());
310 }
311 });
312 area.closePath();
313 return new Area(area);
314 }
315
316 /**
317 * Creates a new state that is the same as the current state except for that it is using a new center.
318 * @param newCenter The new center coordinate.
319 * @return The new state.
320 * @since 10375
321 */
322 public MapViewState usingCenter(EastNorth newCenter) {
323 return movedTo(getCenter(), newCenter);
324 }
325
326 /**
327 * @param mapViewPoint The reference point.
328 * @param newEastNorthThere The east/north coordinate that should be there.
329 * @return The new state.
330 * @since 10375
331 */
332 public MapViewState movedTo(MapViewPoint mapViewPoint, EastNorth newEastNorthThere) {
333 EastNorth delta = newEastNorthThere.subtract(mapViewPoint.getEastNorth());
334 if (delta.distanceSq(0, 0) < .1e-20) {
335 return this;
336 } else {
337 return new MapViewState(topLeft.add(delta), this);
338 }
339 }
340
341 /**
342 * Creates a new state that is the same as the current state except for that it is using a new scale.
343 * @param newScale The new scale to use.
344 * @return The new state.
345 * @since 10375
346 */
347 public MapViewState usingScale(double newScale) {
348 return new MapViewState(newScale, this);
349 }
350
351 /**
352 * Creates a new state that is the same as the current state except for that it is using the location of the given component.
353 * <p>
354 * The view is moved so that the center is the same as the old center.
355 * @param positon The new location to use.
356 * @return The new state.
357 * @since 10375
358 */
359 public MapViewState usingLocation(JComponent positon) {
360 EastNorth center = this.getCenter().getEastNorth();
361 return new MapViewState(positon, this).usingCenter(center);
362 }
363
364 /**
365 * Creates a state that uses the projection.
366 * @param projection The projection to use.
367 * @return The new state.
368 * @since 10486
369 */
370 public MapViewState usingProjection(Projection projection) {
371 if (projection.equals(this.projecting)) {
372 return this;
373 } else {
374 return new MapViewState(projection, this);
375 }
376 }
377
378 /**
379 * Create the default {@link MapViewState} object for the given map view. The screen position won't be set so that this method can be used
380 * before the view was added to the hirarchy.
381 * @param width The view width
382 * @param height The view height
383 * @return The state
384 * @since 10375
385 */
386 public static MapViewState createDefaultState(int width, int height) {
387 Projection projection = Main.getProjection();
388 double scale = projection.getDefaultZoomInPPD();
389 MapViewState state = new MapViewState(projection, width, height, scale, new EastNorth(0, 0));
390 EastNorth center = calculateDefaultCenter();
391 return state.movedTo(state.getCenter(), center);
392 }
393
394 private static EastNorth calculateDefaultCenter() {
395 Bounds b = Optional.ofNullable(DownloadDialog.getSavedDownloadBounds()).orElseGet(
396 () -> Main.getProjection().getWorldBoundsLatLon());
397 return b.getCenter().getEastNorth();
398 }
399
400 /**
401 * Check if this MapViewState equals another one, disregarding the position
402 * of the JOSM window on screen.
403 * @param other the other MapViewState
404 * @return true if the other MapViewState has the same size, scale, position and projection,
405 * false otherwise
406 */
407 public boolean equalsInWindow(MapViewState other) {
408 return other != null &&
409 this.viewWidth == other.viewWidth &&
410 this.viewHeight == other.viewHeight &&
411 this.scale == other.scale &&
412 Objects.equals(this.topLeft, other.topLeft) &&
413 Objects.equals(this.projecting, other.projecting);
414 }
415
416 /**
417 * A class representing a point in the map view. It allows to convert between the different coordinate systems.
418 * @author Michael Zangl
419 */
420 public abstract class MapViewPoint {
421
422 /**
423 * Get this point in view coordinates.
424 * @return The point in view coordinates.
425 */
426 public Point2D getInView() {
427 return new Point2D.Double(getInViewX(), getInViewY());
428 }
429
430 /**
431 * Get the x coordinate in view space without creating an intermediate object.
432 * @return The x coordinate
433 * @since 10827
434 */
435 public abstract double getInViewX();
436
437 /**
438 * Get the y coordinate in view space without creating an intermediate object.
439 * @return The y coordinate
440 * @since 10827
441 */
442 public abstract double getInViewY();
443
444 /**
445 * Convert this point to window coordinates.
446 * @return The point in window coordinates.
447 */
448 public Point2D getInWindow() {
449 return getUsingCorner(topLeftInWindow);
450 }
451
452 /**
453 * Convert this point to screen coordinates.
454 * @return The point in screen coordinates.
455 */
456 public Point2D getOnScreen() {
457 return getUsingCorner(topLeftOnScreen);
458 }
459
460 private Double getUsingCorner(Point corner) {
461 return new Point2D.Double(corner.getX() + getInViewX(), corner.getY() + getInViewY());
462 }
463
464 /**
465 * Gets the {@link EastNorth} coordinate of this point.
466 * @return The east/north coordinate.
467 */
468 public EastNorth getEastNorth() {
469 return new EastNorth(topLeft.east() + getInViewX() * scale, topLeft.north() - getInViewY() * scale);
470 }
471
472 /**
473 * Create a rectangle from this to the other point.
474 * @param other The other point. Needs to be of the same {@link MapViewState}
475 * @return A rectangle.
476 */
477 public MapViewRectangle rectTo(MapViewPoint other) {
478 return new MapViewRectangle(this, other);
479 }
480
481 /**
482 * Gets the current position in LatLon coordinates according to the current projection.
483 * @return The positon as LatLon.
484 * @see #getLatLonClamped()
485 */
486 public LatLon getLatLon() {
487 return projecting.getBaseProjection().eastNorth2latlon(getEastNorth());
488 }
489
490 /**
491 * Gets the latlon coordinate clamped to the current world area.
492 * @return The lat/lon coordinate
493 * @since 10805
494 */
495 public LatLon getLatLonClamped() {
496 return projecting.eastNorth2latlonClamped(getEastNorth());
497 }
498
499 /**
500 * Add the given offset to this point
501 * @param en The offset in east/north space.
502 * @return The new point
503 * @since 10651
504 */
505 public MapViewPoint add(EastNorth en) {
506 return new MapViewEastNorthPoint(getEastNorth().add(en));
507 }
508
509 /**
510 * Check if this point is inside the view bounds.
511 *
512 * This is the case iff <code>getOutsideRectangleFlags(getViewArea())</code> returns no flags
513 * @return true if it is.
514 * @since 10827
515 */
516 public boolean isInView() {
517 return inRange(getInViewX(), 0, getViewWidth()) && inRange(getInViewY(), 0, getViewHeight());
518 }
519
520 private boolean inRange(double val, int min, double max) {
521 return val >= min && val < max;
522 }
523
524 /**
525 * Gets the direction in which this point is outside of the given view rectangle.
526 * @param rect The rectangle to check agains.
527 * @return The direction in which it is outside of the view, as OUTSIDE_... flags.
528 * @since 10827
529 */
530 public int getOutsideRectangleFlags(MapViewRectangle rect) {
531 Rectangle2D bounds = rect.getInView();
532 int flags = 0;
533 if (getInViewX() < bounds.getMinX()) {
534 flags |= OUTSIDE_LEFT;
535 } else if (getInViewX() > bounds.getMaxX()) {
536 flags |= OUTSIDE_RIGHT;
537 }
538 if (getInViewY() < bounds.getMinY()) {
539 flags |= OUTSIDE_TOP;
540 } else if (getInViewY() > bounds.getMaxY()) {
541 flags |= OUTSIDE_BOTTOM;
542 }
543
544 return flags;
545 }
546
547 /**
548 * Gets the sum of the x/y view distances between the points. |x1 - x2| + |y1 - y2|
549 * @param p2 The other point
550 * @return The norm
551 * @since 10827
552 */
553 public double oneNormInView(MapViewPoint p2) {
554 return Math.abs(getInViewX() - p2.getInViewX()) + Math.abs(getInViewY() - p2.getInViewY());
555 }
556
557 /**
558 * Gets the squared distance between this point and an other point.
559 * @param p2 The other point
560 * @return The squared distance.
561 * @since 10827
562 */
563 public double distanceToInViewSq(MapViewPoint p2) {
564 double dx = getInViewX() - p2.getInViewX();
565 double dy = getInViewY() - p2.getInViewY();
566 return dx * dx + dy * dy;
567 }
568
569 /**
570 * Gets the distance between this point and an other point.
571 * @param p2 The other point
572 * @return The distance.
573 * @since 10827
574 */
575 public double distanceToInView(MapViewPoint p2) {
576 return Math.sqrt(distanceToInViewSq(p2));
577 }
578
579 /**
580 * Do a linear interpolation to the other point
581 * @param p1 The other point
582 * @param i The interpolation factor. 0 is at the current point, 1 at the other point.
583 * @return The new point
584 * @since 10874
585 */
586 public MapViewPoint interpolate(MapViewPoint p1, double i) {
587 return new MapViewViewPoint((1 - i) * getInViewX() + i * p1.getInViewX(), (1 - i) * getInViewY() + i * p1.getInViewY());
588 }
589 }
590
591 private class MapViewViewPoint extends MapViewPoint {
592 private final double x;
593 private final double y;
594
595 MapViewViewPoint(double x, double y) {
596 this.x = x;
597 this.y = y;
598 }
599
600 @Override
601 public double getInViewX() {
602 return x;
603 }
604
605 @Override
606 public double getInViewY() {
607 return y;
608 }
609
610 @Override
611 public String toString() {
612 return "MapViewViewPoint [x=" + x + ", y=" + y + ']';
613 }
614 }
615
616 private class MapViewEastNorthPoint extends MapViewPoint {
617
618 private final EastNorth eastNorth;
619
620 MapViewEastNorthPoint(EastNorth eastNorth) {
621 this.eastNorth = Objects.requireNonNull(eastNorth, "eastNorth");
622 }
623
624 @Override
625 public double getInViewX() {
626 return (eastNorth.east() - topLeft.east()) / scale;
627 }
628
629 @Override
630 public double getInViewY() {
631 return (topLeft.north() - eastNorth.north()) / scale;
632 }
633
634 @Override
635 public EastNorth getEastNorth() {
636 return eastNorth;
637 }
638
639 @Override
640 public String toString() {
641 return "MapViewEastNorthPoint [eastNorth=" + eastNorth + ']';
642 }
643 }
644
645 /**
646 * A rectangle on the MapView. It is rectangular in screen / EastNorth space.
647 * @author Michael Zangl
648 */
649 public class MapViewRectangle {
650 private final MapViewPoint p1;
651 private final MapViewPoint p2;
652
653 /**
654 * Create a new MapViewRectangle
655 * @param p1 The first point to use
656 * @param p2 The second point to use.
657 */
658 MapViewRectangle(MapViewPoint p1, MapViewPoint p2) {
659 this.p1 = p1;
660 this.p2 = p2;
661 }
662
663 /**
664 * Gets the projection bounds for this rectangle.
665 * @return The projection bounds.
666 */
667 public ProjectionBounds getProjectionBounds() {
668 ProjectionBounds b = new ProjectionBounds(p1.getEastNorth());
669 b.extend(p2.getEastNorth());
670 return b;
671 }
672
673 /**
674 * Gets a rough estimate of the bounds by assuming lat/lon are parallel to x/y.
675 * @return The bounds computed by converting the corners of this rectangle.
676 * @see #getLatLonBoundsBox()
677 */
678 public Bounds getCornerBounds() {
679 Bounds b = new Bounds(p1.getLatLon());
680 b.extend(p2.getLatLon());
681 return b;
682 }
683
684 /**
685 * Gets the real bounds that enclose this rectangle.
686 * This is computed respecting that the borders of this rectangle may not be a straignt line in latlon coordinates.
687 * @return The bounds.
688 * @since 10458
689 */
690 public Bounds getLatLonBoundsBox() {
691 // TODO @michael2402: Use hillclimb.
692 return projecting.getBaseProjection().getLatLonBoundsBox(getProjectionBounds());
693 }
694
695 /**
696 * Gets this rectangle on the screen.
697 * @return The rectangle.
698 * @since 10651
699 */
700 public Rectangle2D getInView() {
701 double x1 = p1.getInViewX();
702 double y1 = p1.getInViewY();
703 double x2 = p2.getInViewX();
704 double y2 = p2.getInViewY();
705 return new Rectangle2D.Double(Math.min(x1, x2), Math.min(y1, y2), Math.abs(x1 - x2), Math.abs(y1 - y2));
706 }
707
708 /**
709 * Check if the rectangle intersects the map view area.
710 * @return <code>true</code> if it intersects.
711 * @since 10827
712 */
713 public boolean isInView() {
714 return getInView().intersects(getViewArea().getInView());
715 }
716
717 /**
718 * Gets the entry point at which a line between start and end enters the current view.
719 * @param start The start
720 * @param end The end
721 * @return The entry point or <code>null</code> if the line does not intersect this view.
722 */
723 public MapViewPoint getLineEntry(MapViewPoint start, MapViewPoint end) {
724 ProjectionBounds bounds = getProjectionBounds();
725 if (bounds.contains(start.getEastNorth())) {
726 return start;
727 }
728
729 double dx = end.getEastNorth().east() - start.getEastNorth().east();
730 double boundX = dx > 0 ? bounds.minEast : bounds.maxEast;
731 EastNorth borderIntersection = Geometry.getSegmentSegmentIntersection(start.getEastNorth(), end.getEastNorth(),
732 new EastNorth(boundX, bounds.minNorth),
733 new EastNorth(boundX, bounds.maxNorth));
734 if (borderIntersection != null) {
735 return getPointFor(borderIntersection);
736 }
737
738 double dy = end.getEastNorth().north() - start.getEastNorth().north();
739 double boundY = dy > 0 ? bounds.minNorth : bounds.maxNorth;
740 borderIntersection = Geometry.getSegmentSegmentIntersection(start.getEastNorth(), end.getEastNorth(),
741 new EastNorth(bounds.minEast, boundY),
742 new EastNorth(bounds.maxEast, boundY));
743 if (borderIntersection != null) {
744 return getPointFor(borderIntersection);
745 }
746
747 return null;
748 }
749 }
750
751}
Note: See TracBrowser for help on using the repository browser.