#include #include #include #include #include #include #include #include namespace DB { namespace { class DataTypeCustomPointSerialization : public DataTypeCustomSimpleTextSerialization { private: DataTypePtr tuple; public: DataTypeCustomPointSerialization() : tuple(std::make_unique( DataTypes({std::make_unique(), std::make_unique()}))) {} void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings & settings) const override { tuple->serializeAsText(column, row_num, ostr, settings); } void deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const override { tuple->deserializeAsWholeText(column, istr, settings); } }; class DataTypeCustomPolygonSerialization : public DataTypeCustomSimpleTextSerialization { private: DataTypePtr array; public: DataTypeCustomPolygonSerialization() : array(std::make_unique(std::make_unique(std::make_unique( DataTypes({std::make_unique(), std::make_unique()}))))) {} void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings & settings) const override { array->serializeAsText(column, row_num, ostr, settings); } void deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const override { array->deserializeAsWholeText(column, istr, settings); } }; class DataTypeCustomMultiPolygonSerialization : public DataTypeCustomSimpleTextSerialization { private: DataTypePtr array; public: DataTypeCustomMultiPolygonSerialization() : array( std::make_unique(std::make_unique( std::make_unique(std::make_unique( DataTypes({std::make_unique(), std::make_unique()})))))) {} void serializeText(const IColumn & column, size_t row_num, WriteBuffer & ostr, const FormatSettings & settings) const override { array->serializeAsText(column, row_num, ostr, settings); } void deserializeText(IColumn & column, ReadBuffer & istr, const FormatSettings & settings) const override { array->deserializeAsWholeText(column, istr, settings); } }; } void registerDataTypeDomainGeo(DataTypeFactory & factory) { factory.registerSimpleDataTypeCustom("Point", [] { return std::make_pair(DataTypeFactory::instance().get("Tuple(Float64, Float64)"), std::make_unique(std::make_unique("Point"), std::make_unique())); }); factory.registerSimpleDataTypeCustom("Polygon", [] { return std::make_pair(DataTypeFactory::instance().get("Array(Array(Point))"), std::make_unique(std::make_unique("Polygon"), std::make_unique())); }); factory.registerSimpleDataTypeCustom("MultiPolygon", [] { return std::make_pair(DataTypeFactory::instance().get("Array(Polygon)"), std::make_unique(std::make_unique("MultiPolygon"), std::make_unique())); }); } }