<commit_before>#pragma once
#include <boost/date_time/gregorian/gregorian.hpp>
#include <vector>
#include <bitset>

#include <boost/date_time/gregorian/greg_serialize.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/bitset.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/bimap.hpp>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>
namespace mpl = boost::mpl;

namespace navitia { namespace type {
typedef uint32_t idx_t;
const idx_t invalid_idx = std::numeric_limits<idx_t>::max();

enum class Type_e {
    eValidityPattern = 0,
    eLine = 1,
    eJourneyPattern = 2,
    eVehicleJourney = 3,
    eStopPoint = 4,
    eStopArea = 5,
    eStopTime = 6,
    eNetwork = 7,
    ePhysicalMode = 8,
    eCommercialMode = 9,
    eCity = 10,
    eConnection = 11,
    eJourneyPatternPoint = 12,
    eDistrict = 13,
    eDepartment = 14,
    eCompany = 15,
    eVehicle = 16,
    eCountry = 17,
    eUnknown = 18,
    eWay = 19,
    eCoord = 20,
    eJourneyPatternPointConnection = 21,
    eAddress = 22,
    eRoute = 23
};
struct PT_Data;
template<class T> std::string T::* name_getter(){return &T::name;}
template<class T> int T::* idx_getter(){return &T::idx;}


struct Nameable{
    std::string name;
    std::string comment;
};



struct NavitiaHeader{
    std::string id;
    idx_t idx;
    std::string uri;
    NavitiaHeader() : idx(invalid_idx){}
    std::vector<idx_t> get(Type_e, const PT_Data &) const {return std::vector<idx_t>();}

};


/** Coordonnées géographiques en WGS84
 */
struct GeographicalCoord{
    GeographicalCoord() : _lon(0), _lat(0) {}
    GeographicalCoord(double lon, double lat) : _lon(lon), _lat(lat) {}
    GeographicalCoord(const GeographicalCoord& coord) : _lon(coord.lon()), _lat(coord.lat()){}
    GeographicalCoord(double x, double y, bool) {set_xy(x, y);}

    double lon() const { return _lon;}
    double lat() const { return _lat;}

    void set_lon(double lon) { this->_lon = lon;}
    void set_lat(double lat) { this->_lat = lat;}
    void set_xy(double x, double y){this->set_lon(x*M_TO_DEG); this->set_lat(y*M_TO_DEG);}

    /// Ordre des coordonnées utilisé par ProximityList
    bool operator<(GeographicalCoord other) const {return this->_lon < other._lon;}

    constexpr static double DEG_TO_RAD = 0.01745329238;
    constexpr static double M_TO_DEG = 1.0/111319.9;
    /** Calcule la distance Grand Arc entre deux nœuds
      *
      * On utilise la formule de Haversine
      * http://en.wikipedia.org/wiki/Law_of_haversines
      *
      * Si c'est des coordonnées non degrés, alors on utilise la distance euclidienne
      */
    double distance_to(const GeographicalCoord & other) const;


    /** Projette un point sur un segment

       Retourne les coordonnées projetées et la distance au segment
       Si le point projeté tombe en dehors du segment, alors ça tombe sur le nœud le plus proche
       htCommercialtp://paulbourke.net/geometry/pointline/
       */
    std::pair<type::GeographicalCoord, float> project(GeographicalCoord segment_start, GeographicalCoord segment_end) const;

    /** Calcule la distance au carré grand arc entre deux points de manière approchée

        Cela sert essentiellement lorsqu'il faut faire plein de comparaisons de distances à un point (par exemple pour proximity list)
    */
    double approx_sqr_distance(const GeographicalCoord &other, double coslat) const{
        static const double EARTH_RADIUS_IN_METERS_SQUARE = 40612548751652.183023;
        double latitudeArc = (this->lat() - other.lat()) * DEG_TO_RAD;
        double longitudeArc = (this->lon() - other.lon()) * DEG_TO_RAD;
        double tmp = coslat * longitudeArc;
        return EARTH_RADIUS_IN_METERS_SQUARE * (latitudeArc*latitudeArc + tmp*tmp);
    }

    template<class Archive> void serialize(Archive & ar, const unsigned int ) {
        ar & _lon & _lat;
    }

private:
    double _lon;
    double _lat;
};

std::ostream & operator<<(std::ostream &_os, const GeographicalCoord & coord);

/** Deux points sont considérés comme étant égaux s'ils sont à moins de 0.1m */
bool operator==(const GeographicalCoord & a, const GeographicalCoord & b);

struct Country: public NavitiaHeader, Nameable {
    const static Type_e type = Type_e::eCountry;
    idx_t main_city_idx;
    std::vector<idx_t> district_list;
    template<class Archive> void serialize(Archive & ar, const unsigned int ) {
        ar & name & main_city_idx & district_list & idx;
    }
    std::vector<idx_t> get(Type_e type, const PT_Data & data) const;

    Country() : main_city_idx(invalid_idx) {}
};

struct District : public NavitiaHeader, Nameable {
    const static Type_e type = Type_e::eDistrict;
    idx_t main_city_idx;
    idx_t country_idx;
    std::vector<idx_t> department_list;
    template<class Archive> void serialize(Archive & ar, const unsigned int ) {
        ar & name & main_city_idx & country_idx & department_list & idx;
    }

    District() : main_city_idx(invalid_idx), country_idx(invalid_idx) {}
};

struct Department : public NavitiaHeader, Nameable {
    const static Type_e type = Type_e::eDepartment;
    idx_t main_city_idx;
    idx_t district_idx;
    std::vector<idx_t> city_list;
    template<class Archive> void serialize(Archive & ar, const unsigned int ) {
        ar & name & main_city_idx & district_idx & city_list & idx & id;
    }

    Department() : main_city_idx(invalid_idx), district_idx(invalid_idx) {}
};


struct City : public NavitiaHeader, Nameable {
    const static Type_e type = Type_e::eCity;
    std::string main_postal_code;
    bool main_city;
    bool use_main_stop_area_property;

    idx_t department_idx;
    GeographicalCoord coord;

    std::vector<idx_t> postal_code_list;
    std::vector<idx_t> stop_area_list;
    std::vector<idx_t> address_list;
    std::vector<idx_t> site_list;
    std::vector<idx_t> stop_point_list;
    std::vector<idx_t> hang_list;
    std::vector<idx_t> odt_list;

    City() : main_city(false), use_main_stop_area_property(false), department_idx(invalid_idx){}

    template<class Archive> void serialize(Archive & ar, const unsigned int ) {
        ar & name & department_idx & coord & idx & uri & main_postal_code & main_city & id;
    }

    std::vector<idx_t> get(Type_e type, const PT_Data & data) const;
};

enum ConnectionType {
    eStopPointConnection,
    eStopAreaConnection,
    eWalkingConnection,
    eVJConnection,
    eGuaranteedConnection
};

struct Connection: public NavitiaHeader{
    const static Type_e type = Type_e::eConnection;
    idx_t departure_stop_point_idx;
    idx_t destination_stop_point_idx;<commit_msg>Connection Type : Ajout des connections garanties<commit_after>#pragma once
#include <boost/date_time/gregorian/gregorian.hpp>
#include <vector>
#include <bitset>

#include <boost/date_time/gregorian/greg_serialize.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/bitset.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/bimap.hpp>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/register/point.hpp>
#include <boost/geometry/geometries/register/linestring.hpp>
namespace mpl = boost::mpl;

namespace navitia { namespace type {
typedef uint32_t idx_t;
const idx_t invalid_idx = std::numeric_limits<idx_t>::max();

enum class Type_e {
    eValidityPattern = 0,
    eLine = 1,
    eJourneyPattern = 2,
    eVehicleJourney = 3,
    eStopPoint = 4,
    eStopArea = 5,
    eStopTime = 6,
    eNetwork = 7,
    ePhysicalMode = 8,
    eCommercialMode = 9,
    eCity = 10,
    eConnection = 11,
    eJourneyPatternPoint = 12,
    eDistrict = 13,
    eDepartment = 14,
    eCompany = 15,
    eVehicle = 16,
    eCountry = 17,
    eUnknown = 18,
    eWay = 19,
    eCoord = 20,
    eJourneyPatternPointConnection = 21,
    eAddress = 22,
    eRoute = 23
};
struct PT_Data;
template<class T> std::string T::* name_getter(){return &T::name;}
template<class T> int T::* idx_getter(){return &T::idx;}


struct Nameable{
    std::string name;
    std::string comment;
};



struct NavitiaHeader{
    std::string id;
    idx_t idx;
    std::string uri;
    NavitiaHeader() : idx(invalid_idx){}
    std::vector<idx_t> get(Type_e, const PT_Data &) const {return std::vector<idx_t>();}

};


/** Coordonnées géographiques en WGS84
 */
struct GeographicalCoord{
    GeographicalCoord() : _lon(0), _lat(0) {}
    GeographicalCoord(double lon, double lat) : _lon(lon), _lat(lat) {}
    GeographicalCoord(const GeographicalCoord& coord) : _lon(coord.lon()), _lat(coord.lat()){}
    GeographicalCoord(double x, double y, bool) {set_xy(x, y);}

    double lon() const { return _lon;}
    double lat() const { return _lat;}

    void set_lon(double lon) { this->_lon = lon;}
    void set_lat(double lat) { this->_lat = lat;}
    void set_xy(double x, double y){this->set_lon(x*M_TO_DEG); this->set_lat(y*M_TO_DEG);}

    /// Ordre des coordonnées utilisé par ProximityList
    bool operator<(GeographicalCoord other) const {return this->_lon < other._lon;}

    constexpr static double DEG_TO_RAD = 0.01745329238;
    constexpr static double M_TO_DEG = 1.0/111319.9;
    /** Calcule la distance Grand Arc entre deux nœuds
      *
      * On utilise la formule de Haversine
      * http://en.wikipedia.org/wiki/Law_of_haversines
      *
      * Si c'est des coordonnées non degrés, alors on utilise la distance euclidienne
      */
    double distance_to(const GeographicalCoord & other) const;


    /** Projette un point sur un segment

       Retourne les coordonnées projetées et la distance au segment
       Si le point projeté tombe en dehors du segment, alors ça tombe sur le nœud le plus proche
       htCommercialtp://paulbourke.net/geometry/pointline/
       */
    std::pair<type::GeographicalCoord, float> project(GeographicalCoord segment_start, GeographicalCoord segment_end) const;

    /** Calcule la distance au carré grand arc entre deux points de manière approchée

        Cela sert essentiellement lorsqu'il faut faire plein de comparaisons de distances à un point (par exemple pour proximity list)
    */
    double approx_sqr_distance(const GeographicalCoord &other, double coslat) const{
        static const double EARTH_RADIUS_IN_METERS_SQUARE = 40612548751652.183023;
        double latitudeArc = (this->lat() - other.lat()) * DEG_TO_RAD;
        double longitudeArc = (this->lon() - other.lon()) * DEG_TO_RAD;
        double tmp = coslat * longitudeArc;
        return EARTH_RADIUS_IN_METERS_SQUARE * (latitudeArc*latitudeArc + tmp*tmp);
    }

    template<class Archive> void serialize(Archive & ar, const unsigned int ) {
        ar & _lon & _lat;
    }

private:
    double _lon;
    double _lat;
};

std::ostream & operator<<(std::ostream &_os, const GeographicalCoord & coord);

/** Deux points sont considérés comme étant égaux s'ils sont à moins de 0.1m */
bool operator==(const GeographicalCoord & a, const GeographicalCoord & b);

struct Country: public NavitiaHeader, Nameable {
    const static Type_e type = Type_e::eCountry;
    idx_t main_city_idx;
    std::vector<idx_t> district_list;
    template<class Archive> void serialize(Archive & ar, const unsigned int ) {
        ar & name & main_city_idx & district_list & idx;
    }
    std::vector<idx_t> get(Type_e type, const PT_Data & data) const;

    Country() : main_city_idx(invalid_idx) {}
};

struct District : public NavitiaHeader, Nameable {
    const static Type_e type = Type_e::eDistrict;
    idx_t main_city_idx;
    idx_t country_idx;
    std::vector<idx_t> department_list;
    template<class Archive> void serialize(Archive & ar, const unsigned int ) {
        ar & name & main_city_idx & country_idx & department_list & idx;
    }

    District() : main_city_idx(invalid_idx), country_idx(invalid_idx) {}
};

struct Department : public NavitiaHeader, Nameable {
    const static Type_e type = Type_e::eDepartment;
    idx_t main_city_idx;
    idx_t district_idx;
    std::vector<idx_t> city_list;
    template<class Archive> void serialize(Archive & ar, const unsigned int ) {
        ar & name & main_city_idx & district_idx & city_list & idx & id;
    }

    Department() : main_city_idx(invalid_idx), district_idx(invalid_idx) {}
};


struct City : public NavitiaHeader, Nameable {
    const static Type_e type = Type_e::eCity;
    std::string main_postal_code;
    bool main_city;
    bool use_main_stop_area_property;

    idx_t department_idx;
    GeographicalCoord coord;

    std::vector<idx_t> postal_code_list;
    std::vector<idx_t> stop_area_list;
    std::vector<idx_t> address_list;
    std::vector<idx_t> site_list;
    std::vector<idx_t> stop_point_list;
    std::vector<idx_t> hang_list;
    std::vector<idx_t> odt_list;

    City() : main_city(false), use_main_stop_area_property(false), department_idx(invalid_idx){}

    template<class Archive> void serialize(Archive & ar, const unsigned int ) {
        ar & name & department_idx & coord & idx & uri & main_postal_code & main_city & id;
    }

    std::vector<idx_t> get(Type_e type, const PT_Data & data) const;
};

enum ConnectionType {
    eStopPointConnection,
    eStopAreaConnection,
    eWalkingConnection,
    eVJConnection,
    eGuaranteedConnection,

};

struct Connection: public NavitiaHeader{
    const static Type_e type = Type_e::eConnection;
    idx_t departure_stop_point_idx;
    idx_t destination_stop_point_idx;
{'fraction_non_alphanumeric': 0.10416973626049801, 'fraction_numerical': 0.012818623839693531, 'mean_word_length': 3.8344017094017095, 'pattern_counts': {'":': 0, '<': 81, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6915736', 'n_tokens_mistral': 4725, 'n_tokens_neox': 4487, 'n_words': 1136}