Fixes issue #73.
This commit is contained in:
parent
f68d53ead6
commit
8a665bc044
@ -358,7 +358,7 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loadBlock(_ThreadData * threadData) {
|
void loadBlock(_ThreadData * threadData) {
|
||||||
blockCount++;
|
++blockCount;
|
||||||
threadData->currentGroupID = 0;
|
threadData->currentGroupID = 0;
|
||||||
threadData->currentEntityID = 0;
|
threadData->currentEntityID = 0;
|
||||||
}
|
}
|
||||||
@ -380,14 +380,14 @@ private:
|
|||||||
if ( size > MAX_BLOB_HEADER_SIZE || size < 0 ) {
|
if ( size > MAX_BLOB_HEADER_SIZE || size < 0 ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
char *data = (char*)malloc(size);
|
char *data = new char[size];
|
||||||
stream.read(data, size*sizeof(data[0]));
|
stream.read(data, size*sizeof(data[0]));
|
||||||
|
|
||||||
if ( !(threadData->PBFBlobHeader).ParseFromArray( data, size ) ){
|
if ( !(threadData->PBFBlobHeader).ParseFromArray( data, size ) ){
|
||||||
free(data);
|
delete[] data;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
free(data);
|
delete[] data;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,25 +487,26 @@ private:
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !readPBFBlobHeader(stream, threadData) )
|
if ( !readPBFBlobHeader(stream, threadData) ){
|
||||||
return false;
|
|
||||||
|
|
||||||
if ( threadData->PBFBlobHeader.type() != "OSMData" ) {
|
|
||||||
std::cerr << "[error] invalid block type, found" << threadData->PBFBlobHeader.type().data() << "instead of OSMData" << std::endl;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !readBlob(stream, threadData) )
|
if ( threadData->PBFBlobHeader.type() != "OSMData" ) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !readBlob(stream, threadData) ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if ( !threadData->PBFprimitiveBlock.ParseFromArray( &(threadData->charBuffer[0]), threadData-> charBuffer.size() ) ) {
|
if ( !threadData->PBFprimitiveBlock.ParseFromArray( &(threadData->charBuffer[0]), threadData-> charBuffer.size() ) ) {
|
||||||
std::cerr << "[error] failed to parse PrimitiveBlock" << std::endl;
|
ERR("failed to parse PrimitiveBlock");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Endianness getMachineEndianness() {
|
Endianness getMachineEndianness() const {
|
||||||
int i(1);
|
int i(1);
|
||||||
char *p = (char *) &i;
|
char *p = (char *) &i;
|
||||||
if (p[0] == 1)
|
if (p[0] == 1)
|
||||||
|
@ -60,7 +60,7 @@ unsigned globalRestrictionCounter = 0;
|
|||||||
ExtractorCallbacks * extractCallBacks;
|
ExtractorCallbacks * extractCallBacks;
|
||||||
|
|
||||||
bool nodeFunction(_Node n);
|
bool nodeFunction(_Node n);
|
||||||
bool adressFunction(_Node n, HashTable<string, string> keyVals);
|
bool adressFunction(_Node n, HashTable<string, string> & keyVals);
|
||||||
bool restrictionFunction(_RawRestrictionContainer r);
|
bool restrictionFunction(_RawRestrictionContainer r);
|
||||||
bool wayFunction(_Way w);
|
bool wayFunction(_Way w);
|
||||||
|
|
||||||
@ -190,10 +190,9 @@ int main (int argc, char *argv[]) {
|
|||||||
parser = new XMLParser(argv[1]);
|
parser = new XMLParser(argv[1]);
|
||||||
}
|
}
|
||||||
parser->RegisterCallbacks(&nodeFunction, &restrictionFunction, &wayFunction, &adressFunction);
|
parser->RegisterCallbacks(&nodeFunction, &restrictionFunction, &wayFunction, &adressFunction);
|
||||||
GUARANTEE(parser->Init(), "Parser not initialized!");
|
if(!parser->Init())
|
||||||
|
INFO("Parser not initialized!");
|
||||||
parser->Parse();
|
parser->Parse();
|
||||||
DELETE(parser);
|
|
||||||
stringMap.clear();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// INFO("raw no. of names: " << externalMemory.nameVector.size());
|
// INFO("raw no. of names: " << externalMemory.nameVector.size());
|
||||||
@ -485,7 +484,9 @@ int main (int argc, char *argv[]) {
|
|||||||
cerr << "Caught Execption:" << e.what() << endl;
|
cerr << "Caught Execption:" << e.what() << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
DELETE(parser);
|
||||||
|
|
||||||
|
stringMap.clear();
|
||||||
delete extractCallBacks;
|
delete extractCallBacks;
|
||||||
cout << "[extractor] finished." << endl;
|
cout << "[extractor] finished." << endl;
|
||||||
return 0;
|
return 0;
|
||||||
@ -496,7 +497,7 @@ bool nodeFunction(_Node n) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool adressFunction(_Node n, HashTable<string, string> keyVals){
|
bool adressFunction(_Node n, HashTable<string, string> & keyVals){
|
||||||
extractCallBacks->adressFunction(n, keyVals);
|
extractCallBacks->adressFunction(n, keyVals);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user