Codebase list mkgmap / upstream/0.0.0+svn3392
Imported Upstream version 0.0.0+svn3392 Bas Couwenberg 9 years ago
10 changed file(s) with 65 addition(s) and 53 deletion(s). Raw diff Collapse all Expand all
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
589589 * @param val30 a longitude/latitude value with 30 bit precision
590590 * @return an angle in radians.
591591 */
592 private static double int30ToRadians(int val30){
592 public static double int30ToRadians(int val30){
593593 return BIT30_RAD_FACTOR * val30;
594594 }
595595
768768 double deltaLat = bLat - aLat;
769769
770770 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 }
775784
776785 double distance;
777786 if (frac <= 0) {
685685 log.debug("ADD parent-subdiv", parent, srcDivPair.getSource(), ", z=", zoom, " new=", div);
686686 nextList.add(new SourceSubdiv(area, div));
687687 }
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 }
691692 }
692693
693694 srcList = nextList;
7777 this.labels[0] = name;
7878 }
7979
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
8089 public void setLabels(String[] labels) {
8190 this.labels = Arrays.copyOf(labels, 4);
8291 }
168168 housenumberGenerator = new HousenumberGenerator(props);
169169
170170 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 }
182171 if (driveOn == null)
183172 driveOn = "detect,right";
184173 switch (driveOn) {
195184 default:
196185 throw new ExitException("invalid parameters for option drive-on:"+driveOn);
197186 }
198
187
199188 checkRoundabouts = props.getProperty("check-roundabouts",false);
200189 reportDeadEnds = props.getProperty("report-dead-ends", 1);
201190
611600 }
612601 roads = null;
613602
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
620603 for(Relation relation : throughRouteRelations) {
621604 Node node = null;
622605 Way w1 = null;
696679 }
697680 log.info("detected value for driving on left flag is:",dol);
698681 } else {
699 driveOnLeft = ("left".equals(driveOn));
682 dol = ("left".equals(driveOn));
700683 // warn if user given flag is obviously wrong
701684 if ("left".equals(driveOn) && numDriveOnLeftRoads == 0 && numDriveOnRightRoads > 0)
702685 log.warn("The drive-on-left flag is set but tile contains only drive-on-right roads");
508508 * @return {@code true} point lies on the left side; {@code false} point lies on the right side
509509 */
510510 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;
517515 }
518516
519517 /**
530528 } else if (frac >= 1) {
531529 return spoint2.distance(point);
532530 } else {
533 return spoint1.makeBetweenPoint(spoint2, frac).distance(point);
531 return point.distToLineSegment(spoint1, spoint2);
534532 }
535533
536534 }
543541 * @return the fraction
544542 */
545543 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)
551555 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 }
558566 }
559567 }
483483 private boolean isCommonValue(MapElement elem, String name, String value) {
484484 if (name.equals("Label")) {
485485 elem.setName(unescape(recode(value)));
486 } else if (name.equals("Label2") || name.equals("Label3")) {
487 elem.add2Name(unescape(recode(value)));
486488 } else if (name.equals("Levels") || name.equals("EndLevel") || name.equals("LevelsNumber")) {
487489 try {
488490 endLevel = Integer.valueOf(value);
502504 } else if (name.equals("Phone")) {
503505 elem.setPhone(recode(value));
504506 } else if (name.equals("CountryName")) {
505 elem.setCountry(recode(value));
507 elem.setCountry(unescape(recode(value)));
506508 } else if (name.equals("RegionName")) {
507509 //System.out.println("RegionName " + value);
508510 elem.setRegion(recode(value));
100100 roadClass = 0;
101101 if (roadClass > 4)
102102 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;
105105 byte noAccess = 0;
106106 for (int j = 0; j < f.length - 4; j++){
107107 if (Integer.parseInt(f[4+j]) == 0)
112112 break;
113113 case "LBL":
114114 count++;
115 assertEquals("LBL size", 989, size);
115 assertEquals("LBL size", 999, size);
116116 break;
117117 }
118118 }
103103 break;
104104 case "LBL":
105105 count++;
106 assertEquals("LBL size", 989, size);
106 assertEquals("LBL size", 999, size);
107107 break;
108108 case "NET":
109109 count++;
110 assertEquals("NET size", 1280, size);
110 assertEquals("NET size", 1301, size);
111111 break;
112112 case "NOD":
113113 count++;