void Preprocess::Callback::ProcessNode(const OSMId& id, const double& lon, const double& lat, const TagMap& tagMap) { RawNode node; ObjectOSMRef object(id, osmRefNode); if (id<lastNodeId) { nodeSortingError=true; } minCoord.Set(std::min(minCoord.GetLat(),lat), std::min(minCoord.GetLon(),lon)); maxCoord.Set(std::max(maxCoord.GetLat(),lat), std::max(maxCoord.GetLon(),lon)); coordCount++; StoreCoord(id, GeoCoord(lat, lon)); TypeInfoRef type=typeConfig->GetNodeType(tagMap); nodeStat[type->GetIndex()]++; if (!type->GetIgnore()) { node.SetId(id); node.SetType(type); node.SetCoords(lon,lat); node.Parse(progress, *typeConfig, tagMap); node.Write(*typeConfig, nodeWriter); nodeCount++; } lastNodeId=id; }
void Preprocess::ProcessNode(const TypeConfig& typeConfig, const OSMId& id, const double& lon, const double& lat, const std::map<TagId,std::string>& tagMap) { RawNode node; TypeId type=typeIgnore; FileOffset nodeOffset; if (id<lastNodeId) { nodeSortingError=true; } typeConfig.GetNodeTypeId(tagMap,type); if (type!=typeIgnore) { typeConfig.ResolveTags(tagMap,tags); nodeWriter.GetPos(nodeOffset); node.SetId(id); node.SetType(type); node.SetCoords(lon,lat); node.SetTags(tags); node.Write(nodeWriter); nodeCount++; } else { nodeOffset=0; } StoreCoord(id, lat, lon); lastNodeId=id; }
bool NodeDataGenerator::Import(const TypeConfigRef& typeConfig, const ImportParameter& parameter, Progress& progress) { uint32_t rawNodeCount=0; uint32_t nodesReadCount=0; uint32_t nodesWrittenCount=0; // // Iterator over all raw nodes, hcekc they type, and convert them from raw nodes // to nodes if the type is interesting (!=typeIgnore). // // Count the bounding box by the way... // progress.SetAction("Generating nodes.tmp"); FileScanner scanner; FileWriter writer; if (!scanner.Open(AppendFileToDir(parameter.GetDestinationDirectory(), "rawnodes.dat"), FileScanner::Sequential, parameter.GetRawNodeDataMemoryMaped())) { progress.Error("Cannot open 'rawnodes.dat'"); return false; } if (!scanner.Read(rawNodeCount)) { progress.Error("Error while reading number of data entries in file"); return false; } if (!writer.Open(AppendFileToDir(parameter.GetDestinationDirectory(), "nodes.tmp"))) { progress.Error("Cannot create 'nodes.tmp'"); return false; } writer.Write(nodesWrittenCount); for (uint32_t n=1; n<=rawNodeCount; n++) { progress.SetProgress(n,rawNodeCount); RawNode rawNode; Node node; if (!rawNode.Read(typeConfig, scanner)) { progress.Error(std::string("Error while reading data entry ")+ NumberToString(n)+" of "+ NumberToString(rawNodeCount)+ " in file '"+ scanner.GetFilename()+"'"); return false; } nodesReadCount++; if (!rawNode.GetType()->GetIgnore()) { node.SetFeatures(rawNode.GetFeatureValueBuffer()); node.SetCoords(rawNode.GetCoords()); FileOffset fileOffset; if (!writer.GetPos(fileOffset)) { progress.Error(std::string("Error while reading current fileOffset in file '")+ writer.GetFilename()+"'"); return false; } writer.Write(rawNode.GetId()); node.Write(typeConfig, writer); nodesWrittenCount++; } } if (!scanner.Close()) { return false; } writer.SetPos(0); writer.Write(nodesWrittenCount); if (!writer.Close()) { return false; } progress.Info(std::string("Read "+NumberToString(nodesReadCount)+" nodes, wrote "+NumberToString(nodesWrittenCount)+" nodes")); return true; }