This commit is contained in:
Hannes Janetzek
2012-07-23 17:09:27 +02:00
parent c5ace62b61
commit c5c952bf14
57 changed files with 361 additions and 488 deletions

View File

@@ -0,0 +1,19 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.database;
public interface IMapTileData {
}

View File

@@ -41,8 +41,8 @@ public class MapDatabase implements IMapDatabase {
private boolean mOpenFile = false;
private static double radius = 6378137;
private static double D2R = Math.PI / 180;
// private static double radius = 6378137;
// private static double D2R = Math.PI / 180;
// private static double HALF_PI = Math.PI / 2;
@@ -56,23 +56,49 @@ public class MapDatabase implements IMapDatabase {
// float lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 100, tile.zoomLevel) * 1000000;
// float lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 100, tile.zoomLevel) * 1000000;
float lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 100, tile.zoomLevel);
float lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 100, tile.zoomLevel);
float lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 100, tile.zoomLevel);
float lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 100, tile.zoomLevel);
float lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 100,
tile.zoomLevel);
float lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 100,
tile.zoomLevel);
float lat1 = (float) MercatorProjection
.pixelYToLatitude(cy - 100, tile.zoomLevel);
float lat2 = (float) MercatorProjection
.pixelYToLatitude(cy + 100, tile.zoomLevel);
double lonRadians = (D2R * lon1);
double latRadians = (D2R * lat1);
// double lonRadians = (D2R * lon1);
// double latRadians = (D2R * lat1);
// spherical mercator projection
lon1 = (float) (radius * lonRadians);
lat1 = (float) (radius * Math.log(Math.tan(Math.PI * 0.25 + latRadians * 0.5)));
// lon1 = (float) (radius * lonRadians);
// lat1 = (float) (radius * Math.log(Math.tan(Math.PI * 0.25 + latRadians * 0.5)));
//
// lonRadians = (D2R * lon2);
// latRadians = (D2R * lat2);
//
// lon2 = (float) (radius * lonRadians);
// lat2 = (float) (radius * Math.log(Math.tan(Math.PI * 0.25 + latRadians * 0.5)));
//
// mCoords[0] = lon1;
// mCoords[1] = lat1;
//
// mCoords[2] = lon2;
// mCoords[3] = lat1;
//
// mCoords[4] = lon2;
// mCoords[5] = lat2;
//
// mCoords[6] = lon1;
// mCoords[7] = lat2;
//
// mCoords[8] = lon1;
// mCoords[9] = lat1;
//
// mIndex[0] = 10;
lonRadians = (D2R * lon2);
latRadians = (D2R * lat2);
lon2 = (float) (radius * lonRadians);
lat2 = (float) (radius * Math.log(Math.tan(Math.PI * 0.25 + latRadians * 0.5)));
lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 80, tile.zoomLevel) * 1000000;
lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 80, tile.zoomLevel) * 1000000;
lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 80, tile.zoomLevel) * 1000000;
lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 80, tile.zoomLevel) * 1000000;
mCoords[0] = lon1;
mCoords[1] = lat1;
@@ -91,28 +117,6 @@ public class MapDatabase implements IMapDatabase {
mIndex[0] = 10;
// lon1 = (float) MercatorProjection.pixelXToLongitude(cx - 80, tile.zoomLevel) * 1000000;
// lon2 = (float) MercatorProjection.pixelXToLongitude(cx + 80, tile.zoomLevel) * 1000000;
// lat1 = (float) MercatorProjection.pixelYToLatitude(cy - 80, tile.zoomLevel) * 1000000;
// lat2 = (float) MercatorProjection.pixelYToLatitude(cy + 80, tile.zoomLevel) * 1000000;
//
// mCoords[10] = lon1;
// mCoords[11] = lat1;
//
// mCoords[12] = lon2;
// mCoords[13] = lat1;
//
// mCoords[14] = lon2;
// mCoords[15] = lat2;
//
// mCoords[16] = lon1;
// mCoords[17] = lat2;
//
// mCoords[18] = lon1;
// mCoords[19] = lat1;
//
// mIndex[1] = 10;
mapDatabaseCallback.renderWay((byte) 0, mTags, mCoords, mIndex, true);
}

View File

@@ -26,7 +26,7 @@ import java.util.Properties;
import org.mapsforge.core.BoundingBox;
import org.mapsforge.core.GeoPoint;
import org.mapsforge.core.SphericalMercator;
import org.mapsforge.core.WebMercator;
import org.mapsforge.core.Tag;
import org.mapsforge.core.Tile;
import org.mapsforge.database.FileOpenResult;
@@ -54,7 +54,7 @@ public class MapDatabase implements IMapDatabase {
private final MapFileInfo mMapInfo =
new MapFileInfo(new BoundingBox(-180, -85, 180, 85),
new Byte((byte) 14), new GeoPoint(53.11, 8.85),
SphericalMercator.NAME,
WebMercator.NAME,
0, 0, 0, "de", "yo!", "hannes");
// new MapFileInfo(new BoundingBox(-180, -90, 180, 90),
// new Byte((byte) 0), null, "Mercator",
@@ -69,17 +69,12 @@ public class MapDatabase implements IMapDatabase {
private boolean connect() {
Connection conn = null;
// &socketTimeout=15&tcpKeepAlive=true
String dburl = "jdbc:postgresql://city.informatik.uni-bremen.de:5432/gis";
// String dburl = "jdbc:postgresql://city.informatik.uni-bremen.de:5432/planet-2.0";
// String dburl = "jdbc:postgresql://127.0.0.1:5432/bremen";
// String dburl = "jdbc:postgresql://127.0.0.1:5431/planet-2.0";
Properties dbOpts = new Properties();
dbOpts.setProperty("user", "osm");
dbOpts.setProperty("password", "osm");
dbOpts.setProperty("socketTimeout", "30");
dbOpts.setProperty("socketTimeout", "50");
dbOpts.setProperty("tcpKeepAlive", "true");
try {
@@ -94,6 +89,8 @@ public class MapDatabase implements IMapDatabase {
pgconn.addDataType("hstore", PGHStore.class);
conn.createStatement().execute("set statement_timeout to 60000");
} catch (Exception e) {
System.err.println("Aborted due to error:");
e.printStackTrace();
@@ -183,16 +180,8 @@ public class MapDatabase implements IMapDatabase {
}
} catch (SQLException e) {
e.printStackTrace();
// try {
// connection.close();
// } catch (SQLException e1) {
// e1.printStackTrace();
// } finally {
connection = null;
// }
}
}
@Override
@@ -327,6 +316,7 @@ public class MapDatabase implements IMapDatabase {
private void parseGeometryArray(ValueGetter data, int count) {
for (int i = 0; i < count; i++) {
parseGeometry(data);
mIndex[mIndexPos++] = 0;
}
}

View File

@@ -0,0 +1,21 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.mapsforge.database.postgis;
import org.mapsforge.database.IMapTileData;
public class TileData implements IMapTileData {
}