Add public transport platform rendering
This commit is contained in:
parent
a5a25850d4
commit
35bf240ec2
4 changed files with 54 additions and 9 deletions
|
@ -48,7 +48,7 @@ public class BinaryInspector {
|
||||||
// test cases show info
|
// test cases show info
|
||||||
|
|
||||||
|
|
||||||
// inspector(new String[]{"-vaddress", "-bbox=-121.785,37.35,-121.744,37.33", ""});
|
// inspector(new String[]{"-vmap", /*"-bbox=-121.785,37.35,-121.744,37.33", */"/home/victor/projects/OsmAnd/data/osm-gen/Map.obf"});
|
||||||
// test case extract parts
|
// test case extract parts
|
||||||
// test case
|
// test case
|
||||||
}
|
}
|
||||||
|
|
|
@ -361,17 +361,28 @@ public class BinaryMapIndexWriter {
|
||||||
mapDataBuf.clear();
|
mapDataBuf.clear();
|
||||||
int pcalcx = (pleft >> SHIFT_COORDINATES);
|
int pcalcx = (pleft >> SHIFT_COORDINATES);
|
||||||
int pcalcy = (ptop >> SHIFT_COORDINATES);
|
int pcalcy = (ptop >> SHIFT_COORDINATES);
|
||||||
for (int i = 0; i < coordinates.length / 8; i++) {
|
int len = coordinates.length / 8;
|
||||||
|
int delta = 1;
|
||||||
|
for (int i = 0; i < len; i+= delta) {
|
||||||
int x = Algoritms.parseIntFromBytes(coordinates, i * 8);
|
int x = Algoritms.parseIntFromBytes(coordinates, i * 8);
|
||||||
int y = Algoritms.parseIntFromBytes(coordinates, i * 8 + 4);
|
int y = Algoritms.parseIntFromBytes(coordinates, i * 8 + 4);
|
||||||
int tx = (x >> SHIFT_COORDINATES) - pcalcx;
|
int tx = (x >> SHIFT_COORDINATES) - pcalcx;
|
||||||
int ty = (y >> SHIFT_COORDINATES) - pcalcy;
|
int ty = (y >> SHIFT_COORDINATES) - pcalcy;
|
||||||
|
|
||||||
writeRawVarint32(mapDataBuf, CodedOutputStream.encodeZigZag32(tx));
|
writeRawVarint32(mapDataBuf, CodedOutputStream.encodeZigZag32(tx));
|
||||||
writeRawVarint32(mapDataBuf, CodedOutputStream.encodeZigZag32(ty));
|
writeRawVarint32(mapDataBuf, CodedOutputStream.encodeZigZag32(ty));
|
||||||
|
|
||||||
pcalcx = pcalcx + tx ;
|
pcalcx = pcalcx + tx ;
|
||||||
pcalcy = pcalcy + ty ;
|
pcalcy = pcalcy + ty ;
|
||||||
|
delta = 1;
|
||||||
|
// keep first/latest point untouched
|
||||||
|
// just try to skip some points very close to this point
|
||||||
|
while (i + delta < len - 1) {
|
||||||
|
int nx = Algoritms.parseIntFromBytes(coordinates, (i + delta) * 8);
|
||||||
|
int ny = Algoritms.parseIntFromBytes(coordinates, (i + delta) * 8 + 4);
|
||||||
|
if ((Math.abs(x - nx)) >> SHIFT_COORDINATES > 7 || (Math.abs(y - ny)) >> SHIFT_COORDINATES > 7) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
delta++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
COORDINATES_SIZE += CodedOutputStream.computeRawVarint32Size(mapDataBuf.size())
|
COORDINATES_SIZE += CodedOutputStream.computeRawVarint32Size(mapDataBuf.size())
|
||||||
+ CodedOutputStream.computeTagSize(MapData.COORDINATES_FIELD_NUMBER) + mapDataBuf.size();
|
+ CodedOutputStream.computeTagSize(MapData.COORDINATES_FIELD_NUMBER) + mapDataBuf.size();
|
||||||
|
@ -385,7 +396,8 @@ public class BinaryMapIndexWriter {
|
||||||
mapDataBuf.clear();
|
mapDataBuf.clear();
|
||||||
pcalcx = (pleft >> SHIFT_COORDINATES);
|
pcalcx = (pleft >> SHIFT_COORDINATES);
|
||||||
pcalcy = (ptop >> SHIFT_COORDINATES);
|
pcalcy = (ptop >> SHIFT_COORDINATES);
|
||||||
for (int i = 0; i < innerPolygonTypes.length / 8; i++) {
|
len = innerPolygonTypes.length / 8;
|
||||||
|
for (int i = 0; i < len; i+= delta) {
|
||||||
int x = Algoritms.parseIntFromBytes(innerPolygonTypes, i * 8);
|
int x = Algoritms.parseIntFromBytes(innerPolygonTypes, i * 8);
|
||||||
int y = Algoritms.parseIntFromBytes(innerPolygonTypes, i * 8 + 4);
|
int y = Algoritms.parseIntFromBytes(innerPolygonTypes, i * 8 + 4);
|
||||||
if (x == 0 && y == 0) {
|
if (x == 0 && y == 0) {
|
||||||
|
@ -404,6 +416,23 @@ public class BinaryMapIndexWriter {
|
||||||
|
|
||||||
pcalcx = pcalcx + tx ;
|
pcalcx = pcalcx + tx ;
|
||||||
pcalcy = pcalcy + ty ;
|
pcalcy = pcalcy + ty ;
|
||||||
|
delta = 1;
|
||||||
|
// keep first/latest point untouched
|
||||||
|
// just try to skip some points very close to this point
|
||||||
|
while (i + delta < len - 1) {
|
||||||
|
int nx = Algoritms.parseIntFromBytes(innerPolygonTypes, (i + delta) * 8);
|
||||||
|
int ny = Algoritms.parseIntFromBytes(innerPolygonTypes, (i + delta) * 8 + 4);
|
||||||
|
if(nx == 0 && ny == 0) {
|
||||||
|
if(delta > 1) {
|
||||||
|
delta --;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if ((Math.abs(x - nx)) >> SHIFT_COORDINATES > 7 || (Math.abs(y - ny)) >> SHIFT_COORDINATES > 7) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
delta++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -740,7 +740,7 @@ public class IndexCreator {
|
||||||
public static void main(String[] args) throws IOException, SAXException, SQLException, InterruptedException {
|
public static void main(String[] args) throws IOException, SAXException, SQLException, InterruptedException {
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
IndexCreator creator = new IndexCreator(new File("/home/victor/projects/OsmAnd/data/osm-gen/")); //$NON-NLS-1$
|
IndexCreator creator = new IndexCreator(new File("/home/victor/projects/OsmAnd/data/osm-gen/")); //$NON-NLS-1$
|
||||||
creator.setIndexMap(false);
|
creator.setIndexMap(true);
|
||||||
creator.setIndexAddress(true);
|
creator.setIndexAddress(true);
|
||||||
creator.setIndexPOI(true);
|
creator.setIndexPOI(true);
|
||||||
creator.setIndexTransport(false);
|
creator.setIndexTransport(false);
|
||||||
|
|
|
@ -566,9 +566,25 @@ public class MapPanel extends JPanel implements IMapDownloaderCallback {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getMaximumZoomSupported(){
|
||||||
|
if(nativeLibRendering != null) {
|
||||||
|
return 21;
|
||||||
|
}
|
||||||
|
if (map == null) {
|
||||||
|
return 18;
|
||||||
|
}
|
||||||
|
return map.getMaximumZoomSupported();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinimumZoomSupported(){
|
||||||
|
if(nativeLibRendering != null || map == null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return map.getMinimumZoomSupported();
|
||||||
|
}
|
||||||
|
|
||||||
public void setZoom(int zoom){
|
public void setZoom(int zoom){
|
||||||
if(map != null && (zoom > map.getMaximumZoomSupported() || zoom < map.getMinimumZoomSupported())){
|
if(map != null && (zoom > getMaximumZoomSupported() || zoom < getMinimumZoomSupported())){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.zoom = zoom;
|
this.zoom = zoom;
|
||||||
|
@ -690,12 +706,12 @@ public class MapPanel extends JPanel implements IMapDownloaderCallback {
|
||||||
}
|
}
|
||||||
if(e.getID() == KeyEvent.KEY_TYPED){
|
if(e.getID() == KeyEvent.KEY_TYPED){
|
||||||
if(e.getKeyChar() == '+' || e.getKeyChar() == '=' ){
|
if(e.getKeyChar() == '+' || e.getKeyChar() == '=' ){
|
||||||
if(zoom < map.getMaximumZoomSupported()){
|
if(zoom < getMaximumZoomSupported()){
|
||||||
zoom ++;
|
zoom ++;
|
||||||
processed = true;
|
processed = true;
|
||||||
}
|
}
|
||||||
} else if(e.getKeyChar() == '-'){
|
} else if(e.getKeyChar() == '-'){
|
||||||
if(zoom > map.getMinimumZoomSupported()){
|
if(zoom > getMinimumZoomSupported()){
|
||||||
zoom --;
|
zoom --;
|
||||||
processed = true;
|
processed = true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue