MCPcopy Create free account
hub / github.com/comaps/comaps / ToXML

Function ToXML

libs/editor/xml_feature.cpp:791–832  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

789}
790
791XMLFeature ToXML(osm::EditableMapObject const & object, bool serializeType)
792{
793 bool const isPoint = object.GetGeomType() == feature::GeomType::Point;
794 XMLFeature toFeature(isPoint ? XMLFeature::Type::Node : XMLFeature::Type::Way);
795
796 if (isPoint)
797 {
798 toFeature.SetCenter(object.GetMercator());
799 }
800 else
801 {
802 auto const & triangles = object.GetTriangesAsPoints();
803 toFeature.SetGeometry(begin(triangles), end(triangles));
804 }
805
806 if (serializeType)
807 {
808 feature::TypesHolder types = object.GetTypes();
809 types.SortBySpec();
810 ASSERT(!types.Empty(), ("Feature does not have a type"));
811 uint32_t mainType = types.front();
812 toFeature.SetOSMTagsForType(mainType);
813 }
814
815 object.GetNameMultilang().ForEach([&toFeature](uint8_t const & lang, string_view name)
816 { toFeature.SetName(lang, name); });
817
818 string const & house = object.GetHouseNumber();
819 if (!house.empty())
820 toFeature.SetHouse(house);
821
822 auto const cuisines = object.GetCuisines();
823 if (!cuisines.empty())
824 {
825 auto const cuisineStr = strings::JoinStrings(cuisines, ";");
826 toFeature.SetCuisine(cuisineStr);
827 }
828
829 object.ForEachMetadataItem([&toFeature](string_view tag, string_view value) { toFeature.SetTagValue(tag, value); });
830
831 return toFeature;
832}
833
834XMLFeature TypeToXML(uint32_t type, feature::GeomType geomType, m2::PointD mercator)
835{

Callers 3

SaveMethod · 0.85
GenerateUploadedFeatureFunction · 0.85
UNIT_TESTFunction · 0.85

Calls 15

ASSERTFunction · 0.85
JoinStringsFunction · 0.85
SortBySpecMethod · 0.80
frontMethod · 0.80
SetOSMTagsForTypeMethod · 0.80
GetHouseNumberMethod · 0.80
SetHouseMethod · 0.80
GetCuisinesMethod · 0.80
SetCuisineMethod · 0.80
ForEachMetadataItemMethod · 0.80
SetTagValueMethod · 0.80
beginFunction · 0.50

Tested by 2

GenerateUploadedFeatureFunction · 0.68
UNIT_TESTFunction · 0.68