Imported Upstream version 0.0.0+svn3392
Bas Couwenberg
9 years ago
0 | svn.version: 3383 | |
1 | build.timestamp: 2014-12-18T07:11:34+0000 | |
0 | svn.version: 3392 | |
1 | build.timestamp: 2014-12-24T17:03:01+0000 |
589 | 589 | * @param val30 a longitude/latitude value with 30 bit precision |
590 | 590 | * @return an angle in radians. |
591 | 591 | */ |
592 | private static double int30ToRadians(int val30){ | |
592 | public static double int30ToRadians(int val30){ | |
593 | 593 | return BIT30_RAD_FACTOR * val30; |
594 | 594 | } |
595 | 595 | |
768 | 768 | double deltaLat = bLat - aLat; |
769 | 769 | |
770 | 770 | double frac; |
771 | if (deltaLon == 0 && deltaLat == 0) | |
772 | frac = 0; | |
773 | else | |
774 | frac = ((pLon - aLon) * deltaLon + (pLat - aLat) * deltaLat) / (deltaLon * deltaLon + deltaLat * deltaLat); | |
771 | if (deltaLon == 0 && deltaLat == 0){ | |
772 | frac = 0; | |
773 | } | |
774 | else { | |
775 | // scale for longitude deltas by cosine of average latitude | |
776 | double scale = Math.cos(Coord.int30ToRadians((aLat + bLat + pLat) / 3) ); | |
777 | double deltaLonAP = scale * (pLon - aLon); | |
778 | deltaLon = scale * deltaLon; | |
779 | if (deltaLon == 0 && deltaLat == 0) | |
780 | frac = 0; | |
781 | else | |
782 | frac = (deltaLonAP * deltaLon + (pLat - aLat) * deltaLat) / (deltaLon * deltaLon + deltaLat * deltaLat); | |
783 | } | |
775 | 784 | |
776 | 785 | double distance; |
777 | 786 | if (frac <= 0) { |
685 | 685 | log.debug("ADD parent-subdiv", parent, srcDivPair.getSource(), ", z=", zoom, " new=", div); |
686 | 686 | nextList.add(new SourceSubdiv(area, div)); |
687 | 687 | } |
688 | ||
689 | Subdivision lastdiv = nextList.get(nextList.size() - 1).getSubdiv(); | |
690 | lastdiv.setLast(true); | |
688 | if (nextList.size() > 0){ | |
689 | Subdivision lastdiv = nextList.get(nextList.size() - 1).getSubdiv(); | |
690 | lastdiv.setLast(true); | |
691 | } | |
691 | 692 | } |
692 | 693 | |
693 | 694 | srcList = nextList; |
77 | 77 | this.labels[0] = name; |
78 | 78 | } |
79 | 79 | |
80 | public void add2Name(String name) { | |
81 | for (int i = 1; i < 4; i++) { | |
82 | if (this.labels[i] == null) { | |
83 | this.labels[i] = name; | |
84 | break; | |
85 | } | |
86 | } | |
87 | } | |
88 | ||
80 | 89 | public void setLabels(String[] labels) { |
81 | 90 | this.labels = Arrays.copyOf(labels, 4); |
82 | 91 | } |
168 | 168 | housenumberGenerator = new HousenumberGenerator(props); |
169 | 169 | |
170 | 170 | driveOn = props.getProperty("drive-on", null); |
171 | if (driveOn == null){ | |
172 | // support legacy options --drive-on-left and --drive-on-right | |
173 | boolean dol = props.getProperty("drive-on-left", false); | |
174 | boolean dor = props.getProperty("drive-on-right", false); | |
175 | if (dol && dor) | |
176 | throw new ExitException("options drive-on-left and drive-on-right and mutually exclusive"); | |
177 | if (dol) | |
178 | driveOn = "left"; | |
179 | if (dor) | |
180 | driveOn = "right"; | |
181 | } | |
182 | 171 | if (driveOn == null) |
183 | 172 | driveOn = "detect,right"; |
184 | 173 | switch (driveOn) { |
195 | 184 | default: |
196 | 185 | throw new ExitException("invalid parameters for option drive-on:"+driveOn); |
197 | 186 | } |
198 | ||
187 | ||
199 | 188 | checkRoundabouts = props.getProperty("check-roundabouts",false); |
200 | 189 | reportDeadEnds = props.getProperty("report-dead-ends", 1); |
201 | 190 | |
611 | 600 | } |
612 | 601 | roads = null; |
613 | 602 | |
614 | // at this point the check-roundabout option might have changed the driveOn value | |
615 | // if ("left".equals(driveOn) && !ignoreDriveOn){ | |
616 | // NODHeader.setDriveOnLeft(true); | |
617 | // TREHeader.setDriveOnLeft(true); | |
618 | // } | |
619 | ||
620 | 603 | for(Relation relation : throughRouteRelations) { |
621 | 604 | Node node = null; |
622 | 605 | Way w1 = null; |
696 | 679 | } |
697 | 680 | log.info("detected value for driving on left flag is:",dol); |
698 | 681 | } else { |
699 | driveOnLeft = ("left".equals(driveOn)); | |
682 | dol = ("left".equals(driveOn)); | |
700 | 683 | // warn if user given flag is obviously wrong |
701 | 684 | if ("left".equals(driveOn) && numDriveOnLeftRoads == 0 && numDriveOnRightRoads > 0) |
702 | 685 | log.warn("The drive-on-left flag is set but tile contains only drive-on-right roads"); |
508 | 508 | * @return {@code true} point lies on the left side; {@code false} point lies on the right side |
509 | 509 | */ |
510 | 510 | private static boolean isLeft(Coord spoint1, Coord spoint2, Coord point) { |
511 | ||
512 | boolean left = ((spoint2.getLongitude() - spoint1.getLongitude()) | |
513 | * (point.getLatitude() - spoint1.getLatitude()) - (spoint2.getLatitude() - spoint1 | |
514 | .getLatitude()) * (point.getLongitude() - spoint1.getLongitude())) > 0; | |
515 | ||
516 | return left; | |
511 | return ((spoint2.getHighPrecLon() - spoint1.getHighPrecLon()) | |
512 | * (point.getHighPrecLat() - spoint1.getHighPrecLat()) - (spoint2 | |
513 | .getHighPrecLat() - spoint1.getHighPrecLat()) | |
514 | * (point.getHighPrecLon() - spoint1.getHighPrecLon())) > 0; | |
517 | 515 | } |
518 | 516 | |
519 | 517 | /** |
530 | 528 | } else if (frac >= 1) { |
531 | 529 | return spoint2.distance(point); |
532 | 530 | } else { |
533 | return spoint1.makeBetweenPoint(spoint2, frac).distance(point); | |
531 | return point.distToLineSegment(spoint1, spoint2); | |
534 | 532 | } |
535 | 533 | |
536 | 534 | } |
543 | 541 | * @return the fraction |
544 | 542 | */ |
545 | 543 | private static double getFrac(Coord spoint1, Coord spoint2, Coord point) { |
546 | ||
547 | double dx = spoint2.getLongitude() - spoint1.getLongitude(); | |
548 | double dy = spoint2.getLatitude() - spoint1.getLatitude(); | |
549 | ||
550 | if ((dx == 0) && (dy == 0)) { | |
544 | int aLon = spoint1.getHighPrecLon(); | |
545 | int bLon = spoint2.getHighPrecLon(); | |
546 | int pLon = point.getHighPrecLon(); | |
547 | int aLat = spoint1.getHighPrecLat(); | |
548 | int bLat = spoint2.getHighPrecLat(); | |
549 | int pLat = point.getHighPrecLat(); | |
550 | ||
551 | double deltaLon = bLon - aLon; | |
552 | double deltaLat = bLat - aLat; | |
553 | ||
554 | if (deltaLon == 0 && deltaLat == 0) | |
551 | 555 | return 0; |
552 | } | |
553 | ||
554 | return ((point.getLongitude() - spoint1.getLongitude()) * dx + (point | |
555 | .getLatitude() - spoint1.getLatitude()) * dy) | |
556 | / (dx * dx + dy * dy); | |
557 | ||
556 | else { | |
557 | // scale for longitude deltas by cosine of average latitude | |
558 | double scale = Math.cos(Coord.int30ToRadians((aLat + bLat + pLat) / 3) ); | |
559 | double deltaLonAP = scale * (pLon - aLon); | |
560 | deltaLon = scale * deltaLon; | |
561 | if (deltaLon == 0 && deltaLat == 0) | |
562 | return 0; | |
563 | else | |
564 | return (deltaLonAP * deltaLon + (pLat - aLat) * deltaLat) / (deltaLon * deltaLon + deltaLat * deltaLat); | |
565 | } | |
558 | 566 | } |
559 | 567 | } |
483 | 483 | private boolean isCommonValue(MapElement elem, String name, String value) { |
484 | 484 | if (name.equals("Label")) { |
485 | 485 | elem.setName(unescape(recode(value))); |
486 | } else if (name.equals("Label2") || name.equals("Label3")) { | |
487 | elem.add2Name(unescape(recode(value))); | |
486 | 488 | } else if (name.equals("Levels") || name.equals("EndLevel") || name.equals("LevelsNumber")) { |
487 | 489 | try { |
488 | 490 | endLevel = Integer.valueOf(value); |
502 | 504 | } else if (name.equals("Phone")) { |
503 | 505 | elem.setPhone(recode(value)); |
504 | 506 | } else if (name.equals("CountryName")) { |
505 | elem.setCountry(recode(value)); | |
507 | elem.setCountry(unescape(recode(value))); | |
506 | 508 | } else if (name.equals("RegionName")) { |
507 | 509 | //System.out.println("RegionName " + value); |
508 | 510 | elem.setRegion(recode(value)); |
100 | 100 | roadClass = 0; |
101 | 101 | if (roadClass > 4) |
102 | 102 | roadClass = 4; |
103 | oneway = Integer.parseInt(f[2]) > 0; | |
104 | toll = Integer.parseInt(f[3]) > 0; | |
103 | oneway = (f.length > 2) ? Integer.parseInt(f[2]) > 0: false; | |
104 | toll = (f.length > 3) ? Integer.parseInt(f[3]) > 0: false; | |
105 | 105 | byte noAccess = 0; |
106 | 106 | for (int j = 0; j < f.length - 4; j++){ |
107 | 107 | if (Integer.parseInt(f[4+j]) == 0) |
112 | 112 | break; |
113 | 113 | case "LBL": |
114 | 114 | count++; |
115 | assertEquals("LBL size", 989, size); | |
115 | assertEquals("LBL size", 999, size); | |
116 | 116 | break; |
117 | 117 | } |
118 | 118 | } |
103 | 103 | break; |
104 | 104 | case "LBL": |
105 | 105 | count++; |
106 | assertEquals("LBL size", 989, size); | |
106 | assertEquals("LBL size", 999, size); | |
107 | 107 | break; |
108 | 108 | case "NET": |
109 | 109 | count++; |
110 | assertEquals("NET size", 1280, size); | |
110 | assertEquals("NET size", 1301, size); | |
111 | 111 | break; |
112 | 112 | case "NOD": |
113 | 113 | count++; |