comparison flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Line.java @ 4732:7fdddc6ba296

Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
author Sascha Teichmann <sascha.teichmann@intevation.de>
date Fri, 28 Dec 2012 15:01:12 +0100
parents
children ce6b9945bf8e
comparison
equal deleted inserted replaced
4731:7d9fcd322c45 4732:7fdddc6ba296
1 package de.intevation.flys.importer.parsers.tim;
2
3 public class Line {
4
5 public Coordinate a;
6 public Coordinate b;
7
8 public Line() {
9 }
10
11 public Line(Coordinate a, Coordinate b) {
12 this.a = a;
13 this.b = b;
14 }
15
16 /** Project coordinate to line. */
17 public double distanceToFirst(Coordinate c) {
18
19 double nx = b.x - a.x;
20 double ny = b.y - a.y;
21
22 double len = Math.sqrt(nx*nx + ny*ny);
23
24 nx /= len;
25 ny /= len;
26
27 double px = c.x - a.x;
28 double py = c.y - a.y;
29
30 return nx*px + ny*py;
31 }
32 }
33 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org