mirror of
https://codeberg.org/comaps/comaps
synced 2026-01-07 13:03:54 +00:00
[generator] retrieve socket:* OSM tags used by amenity:charging_station
Currently support the following socket types: - type 1 - type 1 combo - type 2 (wired or wo/ cable) - type 2 combo - chademo - nacs This commit also adds initial display of the socket types and power the to Qt desktop app. Signed-off-by: Séverin Lemaignan <severin@guakamole.org>
This commit is contained in:
committed by
skadge
parent
de6953598b
commit
f8d786958a
@@ -194,6 +194,8 @@ bool Metadata::TypeFromString(string_view k, Metadata::EType & outType)
|
||||
outType = Metadata::FMD_OUTDOOR_SEATING;
|
||||
else if (k == "network")
|
||||
outType = Metadata::FMD_NETWORK;
|
||||
else if (k.starts_with("socket:"))
|
||||
outType = Metadata::FMD_CHARGE_SOCKETS;
|
||||
else
|
||||
return false;
|
||||
|
||||
@@ -315,6 +317,7 @@ string ToString(Metadata::EType type)
|
||||
case Metadata::FMD_SELF_SERVICE: return "self_service";
|
||||
case Metadata::FMD_OUTDOOR_SEATING: return "outdoor_seating";
|
||||
case Metadata::FMD_NETWORK: return "network";
|
||||
case Metadata::FMD_CHARGE_SOCKETS: CHECK(false, ("FMD_CHARGE_SOCKETS is a compound attribute."));
|
||||
case Metadata::FMD_COUNT: CHECK(false, ("FMD_COUNT can not be used as a type."));
|
||||
};
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ public:
|
||||
FMD_CHECK_DATE = 53,
|
||||
FMD_CHECK_DATE_OPEN_HOURS = 54,
|
||||
FMD_BRANCH = 55,
|
||||
FMD_CHARGE_SOCKETS = 56,
|
||||
FMD_COUNT
|
||||
};
|
||||
|
||||
|
||||
@@ -178,6 +178,57 @@ std::string_view MapObject::GetOpeningHours() const
|
||||
return m_metadata.Get(MetadataID::FMD_OPEN_HOURS);
|
||||
}
|
||||
|
||||
ChargeSocketDescriptors MapObject::GetChargeSockets() const
|
||||
{
|
||||
ChargeSocketDescriptors sockets;
|
||||
|
||||
auto s = std::string(m_metadata.Get(MetadataID::FMD_CHARGE_SOCKETS));
|
||||
if (s.empty())
|
||||
return sockets;
|
||||
|
||||
auto tokens = strings::Tokenize(s, ";");
|
||||
|
||||
for (auto token : tokens)
|
||||
{
|
||||
if (token.empty())
|
||||
continue;
|
||||
|
||||
auto fields = strings::Tokenize(token, "|");
|
||||
|
||||
if (fields.size() < 3)
|
||||
continue; // invalid entry, skip
|
||||
|
||||
ChargeSocketDescriptor desc;
|
||||
desc.type = fields[0];
|
||||
|
||||
try
|
||||
{
|
||||
desc.count = std::stoi(std::string(fields[1]));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
desc.count = 0;
|
||||
}
|
||||
|
||||
if (fields.size() >= 3)
|
||||
{
|
||||
try
|
||||
{
|
||||
desc.power = std::stod(std::string(fields[2]));
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
desc.power = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
desc.power = 0;
|
||||
|
||||
sockets.push_back(desc);
|
||||
}
|
||||
return sockets;
|
||||
}
|
||||
|
||||
feature::Internet MapObject::GetInternet() const
|
||||
{
|
||||
return feature::InternetFromString(m_metadata.Get(MetadataID::FMD_INTERNET));
|
||||
@@ -242,6 +293,11 @@ int MapObject::GetStars() const
|
||||
return count;
|
||||
}
|
||||
|
||||
std::string MapObject::GetCapacity() const
|
||||
{
|
||||
return std::string(m_metadata.Get(MetadataID::FMD_CAPACITY));
|
||||
}
|
||||
|
||||
bool MapObject::IsPointType() const
|
||||
{
|
||||
return m_geomType == feature::GeomType::Point;
|
||||
|
||||
@@ -17,6 +17,17 @@ namespace osm
|
||||
{
|
||||
class EditableMapObject;
|
||||
|
||||
// struct to store the representation of a charging station socket
|
||||
struct ChargeSocketDescriptor
|
||||
{
|
||||
std::string type; // https://wiki.openstreetmap.org/wiki/Key:socket:*
|
||||
// e.g. "type1"
|
||||
unsigned int count; // number of sockets; 0 means socket present, but unknown count
|
||||
// (eg, OSM tag for count set to 'yes')
|
||||
double power; // power output, in kW. 0 means unknown.
|
||||
};
|
||||
typedef std::vector<ChargeSocketDescriptor> ChargeSocketDescriptors;
|
||||
|
||||
class MapObject
|
||||
{
|
||||
public:
|
||||
@@ -80,9 +91,19 @@ public:
|
||||
|
||||
std::string FormatRoadShields() const;
|
||||
|
||||
/** parses a list of charging station sockets
|
||||
* stored as "<type>|<nb>|[<power>];..." into a vector of
|
||||
* socket descriptors
|
||||
*
|
||||
* For instance:
|
||||
* "type2_combo|2|150;chademo|1|50;type2|4|"
|
||||
*/
|
||||
ChargeSocketDescriptors GetChargeSockets() const;
|
||||
|
||||
std::string_view GetOpeningHours() const;
|
||||
feature::Internet GetInternet() const;
|
||||
int GetStars() const;
|
||||
std::string GetCapacity() const;
|
||||
|
||||
/// @returns true if feature has ATM type.
|
||||
bool HasAtm() const;
|
||||
|
||||
Reference in New Issue
Block a user