ClickHouse/src/DataTypes/DataTypeCustomGeo.cpp

44 lines
1.7 KiB
C++
Raw Normal View History

2020-06-07 16:47:56 +00:00
#include <DataTypes/DataTypeCustomGeo.h>
2020-05-05 14:40:04 +00:00
#include <DataTypes/DataTypeArray.h>
#include <DataTypes/DataTypeCustom.h>
#include <DataTypes/DataTypeFactory.h>
#include <DataTypes/DataTypeTuple.h>
#include <DataTypes/DataTypesNumber.h>
namespace DB
{
2020-05-11 03:31:28 +00:00
void registerDataTypeDomainGeo(DataTypeFactory & factory)
{
2020-05-17 14:02:41 +00:00
// Custom type for point represented as its coordinates stored as Tuple(Float64, Float64)
2020-05-05 14:40:04 +00:00
factory.registerSimpleDataTypeCustom("Point", []
{
return std::make_pair(DataTypeFactory::instance().get("Tuple(Float64, Float64)"),
std::make_unique<DataTypeCustomDesc>(std::make_unique<DataTypePointName>()));
2020-05-05 14:40:04 +00:00
});
// Custom type for simple polygon without holes stored as Array(Point)
factory.registerSimpleDataTypeCustom("Ring", []
{
return std::make_pair(DataTypeFactory::instance().get("Array(Point)"),
std::make_unique<DataTypeCustomDesc>(std::make_unique<DataTypeRingName>()));
});
// Custom type for polygon with holes stored as Array(Ring)
2020-05-17 14:02:41 +00:00
// First element of outer array is outer shape of polygon and all the following are holes
2020-05-05 14:40:04 +00:00
factory.registerSimpleDataTypeCustom("Polygon", []
{
return std::make_pair(DataTypeFactory::instance().get("Array(Ring)"),
std::make_unique<DataTypeCustomDesc>(std::make_unique<DataTypePolygonName>()));
2020-05-05 14:40:04 +00:00
});
2020-05-05 16:47:22 +00:00
2020-05-17 14:02:41 +00:00
// Custom type for multiple polygons with holes stored as Array(Polygon)
2020-05-05 16:47:22 +00:00
factory.registerSimpleDataTypeCustom("MultiPolygon", []
{
return std::make_pair(DataTypeFactory::instance().get("Array(Polygon)"),
std::make_unique<DataTypeCustomDesc>(std::make_unique<DataTypeMultiPolygonName>()));
2020-05-05 16:47:22 +00:00
});
2020-05-05 14:40:04 +00:00
}
2020-05-10 00:02:30 +00:00
}