Fix makefile

This commit is contained in:
Victor Shcherb 2012-05-02 01:40:36 +02:00
parent 8a8470e825
commit 898456256e
6 changed files with 163 additions and 10 deletions

View file

@ -306,6 +306,7 @@ bool initMapStructure(CodedInputStream* input, BinaryMapFile* file) {
input->PopLimit(oldLimit);
input->Seek(mapIndex.filePointer + mapIndex.length);
file->mapIndexes.push_back(mapIndex);
file->indexes.push_back(new MapIndex(mapIndex));
file->basemap = file->basemap || mapIndex.name.find("basemap") != string::npos;
break;
}

View file

@ -41,11 +41,27 @@ struct MapRoot: MapTreeBounds {
std::vector<MapTreeBounds> bounds;
};
enum PART_INDEXES {
MAP_INDEX = 1,
POI_INDEX,
ADDRESS_INDEX,
TRANSPORT_INDEX,
ROUTING_INDEX,
};
struct MapIndex {
struct BinaryPartIndex {
uint32 length;
int filePointer;
PART_INDEXES type;
std::string name;
BinaryPartIndex(PART_INDEXES tp) : type(tp) {}
};
struct MapIndex : BinaryPartIndex {
std::vector<MapRoot> levels;
HMAP::hash_map<int, tag_value > decodingRules;
@ -62,7 +78,7 @@ struct MapIndex {
HMAP::hash_set< int > positiveLayers;
HMAP::hash_set< int > negativeLayers;
MapIndex(){
MapIndex() : BinaryPartIndex(MAP_INDEX) {
nameEncodingType = refEncodingType = coastlineBrokenEncodingType = coastlineEncodingType = -1;
landEncodingType = onewayAttribute = onewayReverseAttribute = -1;
}
@ -113,6 +129,7 @@ struct BinaryMapFile {
uint32 version;
uint64 dateCreated;
std::vector<MapIndex> mapIndexes;
std::vector<BinaryPartIndex*> indexes;
FILE* f;
bool basemap;

View file

@ -5,6 +5,7 @@
#include <SkImageDecoder.h>
#include <jni.h>
#include <time.h>
#include <math.h>
#include "common.h"
@ -345,3 +346,80 @@ SkBitmap* getCachedBitmap(RenderingContext* rc, const std::string& bitmapResourc
return iconBitmap;
}
inline double getPowZoom(float zoom){
if(zoom >= 0 && zoom - floor(zoom) < 0.05f){
return 1 << ((int)zoom);
} else {
return pow(2, zoom);
}
}
double checkLongitude(double longitude) {
while (longitude < -180 || longitude > 180) {
if (longitude < 0) {
longitude += 360;
} else {
longitude -= 360;
}
}
return longitude;
}
double checkLatitude(double latitude) {
while (latitude < -90 || latitude > 90) {
if (latitude < 0) {
latitude += 180;
} else {
latitude -= 180;
}
}
if (latitude < -85.0511) {
return -85.0511;
} else if (latitude > 85.0511) {
return 85.0511;
}
return latitude;
}
inline double toRadians(double angdeg) {
return angdeg / 180 * M_PI;
}
int get31TileNumberX(double longitude){
longitude = checkLongitude(longitude);
long l = 1l << 31;
return (int)((longitude + 180)/360 * l);
}
int get31TileNumberY( double latitude){
latitude = checkLatitude(latitude);
double eval = log(tan(toRadians(latitude)) + 1/cos(toRadians(latitude)) );
long l = 1l << 31;
if(eval > M_PI){
eval = M_PI;
}
return (int) ((1 - eval / M_PI) / 2 * l);
}
double getLongitudeFromTile(float zoom, double x) {
return x / getPowZoom(zoom) * 360.0 - 180.0;
}
double getLatitudeFromTile(float zoom, double y){
int sign = y < 0 ? -1 : 1;
double result = atan(sign*sinh(M_PI * (1 - 2 * y / getPowZoom(zoom)))) * 180. / M_PI;
return result;
}
double get31LongitudeX(int tileX){
return getLongitudeFromTile(21, tileX /1024.);
}
double get31LatitudeY(int tileY){
return getLatitudeFromTile(21, tileY /1024.);
}

View file

@ -205,4 +205,14 @@ float getDensityValue(RenderingContext* rc, float val);
SkBitmap* getCachedBitmap(RenderingContext* rc, const std::string& bitmapResource);
int get31TileNumberX(double longitude);
int get31TileNumberY( double latitude);
double getLongitudeFromTile(float zoom, double x) ;
double getLatitudeFromTile(float zoom, double y);
double get31LongitudeX(int tileX);
double get31LatitudeY(int tileY);
#endif /*_OSMAND_COMMON_H*/

View file

@ -59,19 +59,66 @@ public:
//
// }
void printFileInformation(const char* fileName, VerboseInfo* info) {
const char* formatBounds(int left, int right, int top, int bottom){
float l = get31LongitudeX(left);
float r = get31LongitudeX(right);
float t = get31LatitudeY(top);
float b = get31LatitudeY(bottom);
char* ch = new char[150];
sprintf(ch, "(left top - right bottom) : %g, %g NE - %g, %g NE", l, t,r, b);
return ch;
}
void printFileInformation(const char* fileName, VerboseInfo* verbose) {
BinaryMapFile* file = initBinaryMapFile(fileName);
std::vector<MapIndex>::iterator it = file->mapIndexes.begin();
std::vector<BinaryPartIndex*>::iterator its = file->indexes.begin();
time_t date = file->dateCreated/1000;
printf("Obf file.\n Version %d, basemap %d, date %s \n", file->version,
file->basemap, ctime(&date));
for (; it != file->mapIndexes.end(); it++) {
printf(" Name : %s \n", it.base()->name.c_str());
std::vector<MapRoot>::iterator rt = it.base()->levels.begin();
for (; rt != it.base()->levels.end(); rt++) {
printf(" Level : %d - %d size %d\n", rt->minZoom, rt->maxZoom, rt->length);
int i = 1;
for (; its != file->indexes.end(); its++, i++) {
BinaryPartIndex* it = *its;
std::string partname = "";
if (it->type == MAP_INDEX) {
partname = "Map";
} else if (it->type == TRANSPORT_INDEX) {
partname = "Transport";
} else if (it->type == POI_INDEX) {
partname = "Poi";
} else if (it->type == ADDRESS_INDEX) {
partname = "Address";
}
printf("%d. %s data %s - %d bytes\n", i, partname.c_str(), it->name.c_str(), it->length);
if (it->type == MAP_INDEX) {
MapIndex* m = ((MapIndex*) it);
int j = 1;
std::vector<MapRoot>::iterator rt = m->levels.begin();
for (; rt != m->levels.end(); rt++) {
const char* ch = formatBounds(rt->left, rt->right, rt->top, rt->bottom);
printf("\t%d.%d Map level minZoom = %d, maxZoom = %d, size = %d bytes \n\t\t Bounds %s \n",
i, j++, rt->minZoom, rt->maxZoom, rt->length, ch);
}
if ((verbose != NULL && verbose->vmap)) {
// FIXME
//printMapDetailInfo(verbose, index);
}
} else if (it->type == TRANSPORT_INDEX) {
// FIXME
// TransportIndex ti = ((TransportIndex) p);
// int sh = (31 - BinaryMapIndexReader.TRANSPORT_STOP_ZOOM);
// println(
// "\t Bounds "
// + formatBounds(ti.getLeft() << sh, ti.getRight() << sh, ti.getTop() << sh,
// ti.getBottom() << sh));
} else if (it->type == POI_INDEX && (verbose != NULL && verbose->vpoi)) {
//printPOIDetailInfo(verbose, index, (PoiRegion) p);
} else if (it->type == ADDRESS_INDEX && (verbose != NULL && verbose->vaddress)) {
// printAddressDetailedInfo(verbose, index);
}
}
}

View file

@ -1,6 +1,6 @@
include Common.mk
CPP_FILE_EXTENSION = cpp
CPP_FILE_EXTENSION = cc
LIBNAME := libproto.a
PREBUILT_DIR = ../jni-prebuilt/linux-x86/
OBJECTS = $(LOCAL_SRC_FILES:%.$(CPP_FILE_EXTENSION)=build/obj/%.o)