void Preprocess::Callback::ProcessWay(const OSMId& id, std::vector<OSMId>& nodes, const TagMap& tagMap) { TypeInfoRef areaType; TypeInfoRef wayType; int isArea=0; // 0==unknown, 1==true, -1==false bool isCoastlineArea=false; RawWay way; bool isCoastline=false; if (nodes.size()<2) { progress.Warning("Way "+ NumberToString(id)+ " has less than two nodes!"); return; } if (id<lastWayId) { waySortingError=true; } way.SetId(id); auto areaTag=tagMap.find(typeConfig->tagArea); if (areaTag==tagMap.end()) { isArea=0; } else if (areaTag->second=="no" || areaTag->second=="false" || areaTag->second=="0") { isArea=-1; } else { isArea=1; } auto naturalTag=tagMap.find(typeConfig->tagNatural); if (naturalTag!=tagMap.end() && naturalTag->second=="coastline") { isCoastline=true; } if (isCoastline) { isCoastlineArea=nodes.size()>3 && (nodes.front()==nodes.back() || isArea==1); } typeConfig->GetWayAreaType(tagMap, wayType, areaType); if (isArea==1 && areaType==typeConfig->typeInfoIgnore) { isArea=0; } else if (isArea==-1 && wayType==typeConfig->typeInfoIgnore) { isArea=0; } if (isArea==0) { if (wayType!=typeConfig->typeInfoIgnore && areaType==typeConfig->typeInfoIgnore) { isArea=-1; } else if (wayType==typeConfig->typeInfoIgnore && areaType!=typeConfig->typeInfoIgnore) { isArea=1; } else if (wayType!=typeConfig->typeInfoIgnore && areaType!=typeConfig->typeInfoIgnore) { if (nodes.size()>3 && nodes.front()==nodes.back()) { if (wayType->GetPinWay()) { isArea=-1; } else { isArea=1; } } else { isArea=-1; } } } switch (isArea) { case 1: areaStat[areaType->GetIndex()]++; if (areaType->GetIgnore()) { way.SetType(typeConfig->typeInfoIgnore, true); } else { way.SetType(areaType,true); } if (nodes.size()>3 && nodes.front()==nodes.back()) { nodes.pop_back(); } areaCount++; break; case -1: wayStat[wayType->GetIndex()]++; if (wayType->GetIgnore()) { way.SetType(typeConfig->typeInfoIgnore,false); } else { way.SetType(wayType,false); } wayCount++; break; default: if (nodes.size()>3 && nodes.front()==nodes.back()) { areaStat[typeIgnore]++; way.SetType(typeConfig->typeInfoIgnore, true); nodes.pop_back(); areaCount++; } else { wayStat[typeIgnore]++; way.SetType(typeConfig->typeInfoIgnore, false); wayCount++; } } way.SetNodes(nodes); way.Parse(progress, *typeConfig, tagMap); way.Write(*typeConfig, wayWriter); lastWayId=id; if (isCoastline) { RawCoastline coastline; coastline.SetId(way.GetId()); coastline.SetType(isCoastlineArea); coastline.SetNodes(way.GetNodes()); coastline.Write(coastlineWriter); coastlineCount++; } }
void Preprocess::ProcessWay(const TypeConfig& typeConfig, const OSMId& id, std::vector<OSMId>& nodes, const std::map<TagId,std::string>& tagMap) { TypeId areaType=typeIgnore; TypeId wayType=typeIgnore; int isArea=0; // 0==unknown, 1==true, -1==false std::map<TagId,std::string>::const_iterator areaTag; std::map<TagId,std::string>::const_iterator naturalTag; RawWay way; bool isCoastline=false; if (id<lastWayId) { waySortingError=true; } way.SetId(id); areaTag=tagMap.find(typeConfig.tagArea); if (areaTag==tagMap.end()) { isArea=0; } else if (areaTag->second=="no" || areaTag->second=="false" || areaTag->second=="0") { isArea=-1; } else { isArea=1; } naturalTag=tagMap.find(typeConfig.tagNatural); if (naturalTag!=tagMap.end() && naturalTag->second=="coastline") { isCoastline=true; } typeConfig.GetWayAreaTypeId(tagMap,wayType,areaType); typeConfig.ResolveTags(tagMap,tags); if (isArea==1 && areaType==typeIgnore) { isArea=0; } else if (isArea==-1 && wayType==typeIgnore) { isArea=0; } if (isArea==0) { if (wayType!=typeIgnore && areaType==typeIgnore) { isArea=-1; } else if (wayType==typeIgnore && areaType!=typeIgnore) { isArea=1; } else if (wayType!=typeIgnore && areaType!=typeIgnore) { if (nodes.size()>3 && nodes.front()==nodes.back()) { if (typeConfig.GetTypeInfo(wayType).GetPinWay()) { isArea=-1; } else { isArea=1; } } else { isArea=-1; } } } switch (isArea) { case 1: way.SetType(areaType,true); if (nodes.size()>3 && nodes.front()==nodes.back()) { nodes.pop_back(); } areaCount++; break; case -1: way.SetType(wayType,false); wayCount++; break; default: if (nodes.size()>3 && nodes.front()==nodes.back()) { way.SetType(typeIgnore, true); nodes.pop_back(); areaCount++; } else { way.SetType(typeIgnore, false); wayCount++; } } way.SetNodes(nodes); way.SetTags(tags); way.Write(wayWriter); lastWayId=id; if (isCoastline) { RawCoastline coastline; coastline.SetId(way.GetId()); coastline.SetType(way.IsArea()); coastline.SetNodes(way.GetNodes()); coastline.Write(coastlineWriter); coastlineCount++; } }