mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
geographic -> spherical
This commit is contained in:
parent
ac03ba31bf
commit
0e1b2d8fcf
@ -102,13 +102,13 @@ std::vector<MultiPolygon<Point>> MultiPolygonFromColumnConverter<Point>::convert
|
||||
|
||||
|
||||
template class PointFromColumnConverter<CartesianPoint>;
|
||||
template class PointFromColumnConverter<GeographicPoint>;
|
||||
template class PointFromColumnConverter<SphericalPoint>;
|
||||
template class RingFromColumnConverter<CartesianPoint>;
|
||||
template class RingFromColumnConverter<GeographicPoint>;
|
||||
template class RingFromColumnConverter<SphericalPoint>;
|
||||
template class PolygonFromColumnConverter<CartesianPoint>;
|
||||
template class PolygonFromColumnConverter<GeographicPoint>;
|
||||
template class PolygonFromColumnConverter<SphericalPoint>;
|
||||
template class MultiPolygonFromColumnConverter<CartesianPoint>;
|
||||
template class MultiPolygonFromColumnConverter<GeographicPoint>;
|
||||
template class MultiPolygonFromColumnConverter<SphericalPoint>;
|
||||
|
||||
template <typename Point, template<typename> typename Desired>
|
||||
void checkColumnTypeOrThrow(const ColumnWithTypeAndName & column)
|
||||
@ -130,8 +130,8 @@ void checkColumnTypeOrThrow(const ColumnWithTypeAndName & column)
|
||||
template void checkColumnTypeOrThrow<CartesianPoint, Ring>(const ColumnWithTypeAndName &);
|
||||
template void checkColumnTypeOrThrow<CartesianPoint, Polygon>(const ColumnWithTypeAndName &);
|
||||
template void checkColumnTypeOrThrow<CartesianPoint, MultiPolygon>(const ColumnWithTypeAndName &);
|
||||
template void checkColumnTypeOrThrow<GeographicPoint, Ring>(const ColumnWithTypeAndName &);
|
||||
template void checkColumnTypeOrThrow<GeographicPoint, Polygon>(const ColumnWithTypeAndName &);
|
||||
template void checkColumnTypeOrThrow<GeographicPoint, MultiPolygon>(const ColumnWithTypeAndName &);
|
||||
template void checkColumnTypeOrThrow<SphericalPoint, Ring>(const ColumnWithTypeAndName &);
|
||||
template void checkColumnTypeOrThrow<SphericalPoint, Polygon>(const ColumnWithTypeAndName &);
|
||||
template void checkColumnTypeOrThrow<SphericalPoint, MultiPolygon>(const ColumnWithTypeAndName &);
|
||||
|
||||
}
|
||||
|
@ -51,12 +51,12 @@ using CartesianPolygon = Polygon<CartesianPoint>;
|
||||
using CartesianMultiPolygon = MultiPolygon<CartesianPoint>;
|
||||
using CartesianGeometry = Geometry<CartesianPoint>;
|
||||
|
||||
// using GeographicPoint = boost::geometry::model::point<Float64, 2, boost::geometry::cs::geographic<boost::geometry::degree>>;
|
||||
using GeographicPoint = boost::geometry::model::point<Float64, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>>;
|
||||
using GeographicRing = Ring<GeographicPoint>;
|
||||
using GeographicPolygon = Polygon<GeographicPoint>;
|
||||
using GeographicMultiPolygon = MultiPolygon<GeographicPoint>;
|
||||
using GeographicGeometry = Geometry<GeographicPoint>;
|
||||
// using SphericalPoint = boost::geometry::model::point<Float64, 2, boost::geometry::cs::Spherical<boost::geometry::degree>>;
|
||||
using SphericalPoint = boost::geometry::model::point<Float64, 2, boost::geometry::cs::spherical_equatorial<boost::geometry::degree>>;
|
||||
using SphericalRing = Ring<SphericalPoint>;
|
||||
using SphericalPolygon = Polygon<SphericalPoint>;
|
||||
using SphericalMultiPolygon = MultiPolygon<SphericalPoint>;
|
||||
using SphericalGeometry = Geometry<SphericalPoint>;
|
||||
|
||||
|
||||
template<class Point>
|
||||
@ -70,7 +70,7 @@ class MultiPolygonFromColumnConverter;
|
||||
|
||||
/**
|
||||
* Class which takes some boost type and returns a pair of numbers.
|
||||
* They are (x,y) in case of cartesian coordinated and (lon,lat) in case of geographic.
|
||||
* They are (x,y) in case of cartesian coordinated and (lon,lat) in case of Spherical.
|
||||
*/
|
||||
template <typename Point>
|
||||
class PointFromColumnConverter
|
||||
@ -151,16 +151,16 @@ private:
|
||||
|
||||
|
||||
extern template class PointFromColumnConverter<CartesianPoint>;
|
||||
extern template class PointFromColumnConverter<GeographicPoint>;
|
||||
extern template class PointFromColumnConverter<SphericalPoint>;
|
||||
extern template class RingFromColumnConverter<CartesianPoint>;
|
||||
extern template class RingFromColumnConverter<GeographicPoint>;
|
||||
extern template class RingFromColumnConverter<SphericalPoint>;
|
||||
extern template class PolygonFromColumnConverter<CartesianPoint>;
|
||||
extern template class PolygonFromColumnConverter<GeographicPoint>;
|
||||
extern template class PolygonFromColumnConverter<SphericalPoint>;
|
||||
extern template class MultiPolygonFromColumnConverter<CartesianPoint>;
|
||||
extern template class MultiPolygonFromColumnConverter<GeographicPoint>;
|
||||
extern template class MultiPolygonFromColumnConverter<SphericalPoint>;
|
||||
|
||||
|
||||
/// To serialize Geographic or Cartesian point (a pair of numbers in both cases).
|
||||
/// To serialize Spherical or Cartesian point (a pair of numbers in both cases).
|
||||
template <typename Point>
|
||||
class PointSerializer
|
||||
{
|
||||
|
@ -19,7 +19,7 @@ namespace ErrorCodes
|
||||
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
|
||||
}
|
||||
|
||||
/** Calculates the distance between two geographical locations.
|
||||
/** Calculates the distance between two Sphericalal locations.
|
||||
* There are three variants:
|
||||
* greatCircleAngle: calculates the distance on a sphere in degrees: https://en.wikipedia.org/wiki/Great-circle_distance
|
||||
* greatCircleDistance: calculates the distance on a sphere in meters.
|
||||
|
@ -118,13 +118,13 @@ template <>
|
||||
const char * FunctionPolygonArea<CartesianPoint>::name = "polygonAreaCartesian";
|
||||
|
||||
template <>
|
||||
const char * FunctionPolygonArea<GeographicPoint>::name = "polygonAreaGeographic";
|
||||
const char * FunctionPolygonArea<SphericalPoint>::name = "polygonAreaSpherical";
|
||||
|
||||
|
||||
void registerFunctionPolygonArea(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionPolygonArea<CartesianPoint>>();
|
||||
factory.registerFunction<FunctionPolygonArea<GeographicPoint>>();
|
||||
factory.registerFunction<FunctionPolygonArea<SphericalPoint>>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -95,13 +95,13 @@ template <>
|
||||
const char * FunctionPolygonPerimeter<CartesianPoint>::name = "polygonPerimeterCartesian";
|
||||
|
||||
template <>
|
||||
const char * FunctionPolygonPerimeter<GeographicPoint>::name = "polygonPerimeterGeographic";
|
||||
const char * FunctionPolygonPerimeter<SphericalPoint>::name = "polygonPerimeterSpherical";
|
||||
|
||||
|
||||
void registerFunctionPolygonPerimeter(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionPolygonPerimeter<CartesianPoint>>();
|
||||
factory.registerFunction<FunctionPolygonPerimeter<GeographicPoint>>();
|
||||
factory.registerFunction<FunctionPolygonPerimeter<SphericalPoint>>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -104,13 +104,13 @@ template <>
|
||||
const char * FunctionPolygonsDistance<CartesianPoint>::name = "polygonsDistanceCartesian";
|
||||
|
||||
template <>
|
||||
const char * FunctionPolygonsDistance<GeographicPoint>::name = "polygonsDistanceGeographic";
|
||||
const char * FunctionPolygonsDistance<SphericalPoint>::name = "polygonsDistanceSpherical";
|
||||
|
||||
|
||||
void registerFunctionPolygonsDistance(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionPolygonsDistance<CartesianPoint>>();
|
||||
factory.registerFunction<FunctionPolygonsDistance<GeographicPoint>>();
|
||||
factory.registerFunction<FunctionPolygonsDistance<SphericalPoint>>();
|
||||
}
|
||||
|
||||
|
||||
|
@ -110,13 +110,13 @@ template <>
|
||||
const char * FunctionPolygonsIntersection<CartesianPoint>::name = "polygonsIntersectionCartesian";
|
||||
|
||||
template <>
|
||||
const char * FunctionPolygonsIntersection<GeographicPoint>::name = "polygonsIntersectionGeographic";
|
||||
const char * FunctionPolygonsIntersection<SphericalPoint>::name = "polygonsIntersectionSpherical";
|
||||
|
||||
|
||||
void registerFunctionPolygonsIntersection(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionPolygonsIntersection<CartesianPoint>>();
|
||||
factory.registerFunction<FunctionPolygonsIntersection<GeographicPoint>>();
|
||||
factory.registerFunction<FunctionPolygonsIntersection<SphericalPoint>>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -105,12 +105,12 @@ template <>
|
||||
const char * FunctionPolygonsSymDifference<CartesianPoint>::name = "polygonsSymDifferenceCartesian";
|
||||
|
||||
template <>
|
||||
const char * FunctionPolygonsSymDifference<GeographicPoint>::name = "polygonsSymDifferenceGeographic";
|
||||
const char * FunctionPolygonsSymDifference<SphericalPoint>::name = "polygonsSymDifferenceSpherical";
|
||||
|
||||
void registerFunctionPolygonsSymDifference(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionPolygonsSymDifference<CartesianPoint>>();
|
||||
factory.registerFunction<FunctionPolygonsSymDifference<GeographicPoint>>();
|
||||
factory.registerFunction<FunctionPolygonsSymDifference<SphericalPoint>>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -108,13 +108,13 @@ template <>
|
||||
const char * FunctionPolygonsUnion<CartesianPoint>::name = "polygonsUnionCartesian";
|
||||
|
||||
template <>
|
||||
const char * FunctionPolygonsUnion<GeographicPoint>::name = "polygonsUnionGeographic";
|
||||
const char * FunctionPolygonsUnion<SphericalPoint>::name = "polygonsUnionSpherical";
|
||||
|
||||
|
||||
void registerFunctionPolygonsUnion(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionPolygonsUnion<CartesianPoint>>();
|
||||
factory.registerFunction<FunctionPolygonsUnion<GeographicPoint>>();
|
||||
factory.registerFunction<FunctionPolygonsUnion<SphericalPoint>>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -107,13 +107,13 @@ template <>
|
||||
const char * FunctionPolygonsWithin<CartesianPoint>::name = "polygonsWithinCartesian";
|
||||
|
||||
template <>
|
||||
const char * FunctionPolygonsWithin<GeographicPoint>::name = "polygonsWithinGeographic";
|
||||
const char * FunctionPolygonsWithin<SphericalPoint>::name = "polygonsWithinSpherical";
|
||||
|
||||
|
||||
void registerFunctionPolygonsWithin(FunctionFactory & factory)
|
||||
{
|
||||
factory.registerFunction<FunctionPolygonsWithin<CartesianPoint>>();
|
||||
factory.registerFunction<FunctionPolygonsWithin<GeographicPoint>>();
|
||||
factory.registerFunction<FunctionPolygonsWithin<SphericalPoint>>();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <Core/Types.h>
|
||||
#include <Functions/geometryConverters.h>
|
||||
|
||||
#include <boost/geometry.hpp>
|
||||
#include <boost/geometry/geometries/point_xy.hpp>
|
||||
#include <boost/geometry/geometries/polygon.hpp>
|
||||
|
||||
namespace bg = boost::geometry;
|
||||
|
||||
TEST(Geometry, Area)
|
||||
{
|
||||
|
||||
DB::GeographicPolygon sph_poly;
|
||||
bg::read_wkt("POLYGON ((33.905868 35.090882, 33.913619 35.090882, 33.921474 35.080702, 33.914446 35.073054, 33.908245 35.070729, 33.906524 35.069122, 33.906506 35.069105, 33.898116 35.061272, 33.880133 35.073054, 33.874655 35.067525, 33.867627 35.060497, 33.855122 35.053417, 33.841169 35.051092, 33.834865 35.056621, 33.827113 35.061272, 33.813781 35.055794, 33.804375 35.049541, 33.799001 35.038534, 33.822359 35.030059, 33.830214 35.023031, 33.829387 35.001176, 33.829387 35.001172, 33.840342 34.993369, 33.859049 34.991819, 33.859049 34.974662, 33.850471 34.973009, 33.838068 34.963707, 33.84582 34.959728, 33.864423 34.962983, 33.891841 34.958139, 33.8838 34.949123, 33.874522 34.94123, 33.862315 34.937893, 33.847423 34.94245, 33.819672 34.964748, 33.80421 34.972602, 33.781896 34.976212, 33.784945 34.976212, 33.788046 34.976988, 33.7928 34.977763, 33.79435 34.977763, 33.791146 34.982414, 33.786495 34.984687, 33.782568 34.984687, 33.777917 34.984687, 33.77399 34.988666, 33.766135 34.990268, 33.761484 34.990268, 33.75921 34.988666, 33.765411 34.985566, 33.769339 34.983964, 33.770889 34.980088, 33.77554 34.980088, 33.780191 34.979313, 33.780986 34.976338, 33.780935 34.976345, 33.760427 34.979682, 33.717296 34.977769, 33.70152 34.97289, 33.702935 34.987943, 33.711461 34.985566, 33.71544 34.997296, 33.699731 35.002722, 33.69663 35.008975, 33.705312 35.015228, 33.702211 35.022256, 33.685003 35.029284, 33.679444 35.033891, 33.679435 35.033899, 33.675649 35.037036, 33.674099 35.046441, 33.678853 35.055794, 33.69446 35.058171, 33.705312 35.06675, 33.714717 35.06675, 33.719368 35.06277, 33.711461 35.040963, 33.707585 35.029284, 33.718489 35.032385, 33.739677 35.047216, 33.766135 35.03161, 33.77554 35.040188, 33.786495 35.038534, 33.79435 35.040188, 33.798278 35.052642, 33.824012 35.06675, 33.834865 35.063597, 33.842719 35.056621, 33.853571 35.058171, 33.866904 35.06675, 33.871555 35.073054, 33.876929 35.076826, 33.871555 35.085456, 33.871555 35.100236, 33.876206 35.118994, 33.889435 35.118994, 33.891812 35.110468, 33.89884 35.108814, 33.903594 35.099512, 33.905868 35.09636, 33.905868 35.090882), (33.742792 35.001233, 33.746689 35.002711, 33.752063 35.004323, 33.752063 35.0144, 33.746151 35.015207, 33.741314 35.013729, 33.740239 35.010101, 33.738761 35.005264, 33.739702 35.002576, 33.742792 35.001233))", sph_poly);
|
||||
auto area = bg::area(sph_poly);
|
||||
std::cout << std::setprecision (15) << area << std::endl;
|
||||
ASSERT_TRUE(std::abs(area - 127533079.61976177) < 1e-4);
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
select polygonsWithinCartesian([[[(0, 0),(0, 3),(1, 2.9),(2, 2.6),(2.6, 2),(2.9, 1),(3, 0),(0, 0)]]], [[[(1., 1.),(1., 4.),(4., 4.),(4., 1.),(1., 1.)]]]);
|
||||
select polygonsWithinCartesian([[[(2., 2.), (2., 3.), (3., 3.), (3., 2.)]]], [[[(1., 1.),(1., 4.),(4., 4.),(4., 1.),(1., 1.)]]]);
|
||||
|
||||
select polygonsWithinGeographic([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]);
|
||||
select polygonsWithinGeographic([[[(4.3501568, 50.8518269), (4.3444920, 50.8439961), (4.3565941, 50.8443213), (4.3501568, 50.8518269)]]], [[[(4.3679450, 50.8524550),(4.3466930, 50.8583060),(4.3380740, 50.8486770),(4.3449610, 50.8332640),(4.3662270, 50.8408090),(4.3679450, 50.8524550)]]]);
|
||||
select polygonsWithinSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]);
|
||||
select polygonsWithinSpherical([[[(4.3501568, 50.8518269), (4.3444920, 50.8439961), (4.3565941, 50.8443213), (4.3501568, 50.8518269)]]], [[[(4.3679450, 50.8524550),(4.3466930, 50.8583060),(4.3380740, 50.8486770),(4.3449610, 50.8332640),(4.3662270, 50.8408090),(4.3679450, 50.8524550)]]]);
|
||||
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
select polygonsDistanceCartesian([[[(0, 0),(0, 3),(1, 2.9),(2, 2.6),(2.6, 2),(2.9, 1),(3, 0),(0, 0)]]], [[[(1., 1.),(1., 4.),(4., 4.),(4., 1.),(1., 1.)]]]);
|
||||
select polygonsDistanceCartesian([[[(0, 0), (0, 0.1), (0.1, 0.1), (0.1, 0)]]], [[[(1., 1.),(1., 4.),(4., 4.),(4., 1.),(1., 1.)]]]);
|
||||
select polygonsDistanceGeographic([[[(23.725750, 37.971536)]]], [[[(4.3826169, 50.8119483)]]]);
|
||||
select polygonsDistanceSpherical([[[(23.725750, 37.971536)]]], [[[(4.3826169, 50.8119483)]]]);
|
||||
|
||||
drop table if exists polygon_01302;
|
||||
create table polygon_01302 (x Array(Array(Array(Tuple(Float64, Float64)))), y Array(Array(Array(Tuple(Float64, Float64))))) engine=Memory();
|
||||
insert into polygon_01302 values ([[[(23.725750, 37.971536)]]], [[[(4.3826169, 50.8119483)]]]);
|
||||
select polygonsDistanceGeographic(x, y) from polygon_01302;
|
||||
select polygonsDistanceSpherical(x, y) from polygon_01302;
|
||||
|
@ -2,4 +2,4 @@ select polygonsUnionCartesian([[[(0., 0.),(0., 3.),(1., 2.9),(2., 2.6),(2.6, 2.)
|
||||
|
||||
SELECT polygonsUnionCartesian([[[(2., 100.0000991821289), (0., 3.), (1., 2.9), (2., 2.6), (2.6, 2.), (2.9, 1), (3., 0.), (100.0000991821289, 2.)]]], [[[(1., 1.), (1000.0001220703125, nan), (4., 4.), (4., 1.), (1., 1.)]]]); -- { serverError 43 }
|
||||
|
||||
select polygonsUnionGeographic([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]);
|
||||
select polygonsUnionSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]);
|
||||
|
@ -1,5 +1,5 @@
|
||||
select polygonsIntersectionCartesian([[[(0., 0.),(0., 3.),(1., 2.9),(2., 2.6),(2.6, 2.),(2.9, 1.),(3., 0.),(0., 0.)]]], [[[(1., 1.),(1., 4.),(4., 4.),(4., 1.),(1., 1.)]]]);
|
||||
select polygonsIntersectionCartesian([[[(0., 0.),(0., 3.),(1., 2.9),(2., 2.6),(2.6, 2.),(2.9, 1.),(3., 0.),(0., 0.)]]], [[[(3., 3.),(3., 4.),(4., 4.),(4., 3.),(3., 3.)]]]);
|
||||
|
||||
select polygonsIntersectionGeographic([[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]], [[[(25.0010, 136.9987), (17.7500, 142.5000), (11.3733, 142.5917)]]]);
|
||||
select polygonsIntersectionGeographic([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]);
|
||||
select polygonsIntersectionSpherical([[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]], [[[(25.0010, 136.9987), (17.7500, 142.5000), (11.3733, 142.5917)]]]);
|
||||
select polygonsIntersectionSpherical([[[(4.3613577, 50.8651821), (4.349556, 50.8535879), (4.3602419, 50.8435626), (4.3830299, 50.8428851), (4.3904543, 50.8564867), (4.3613148, 50.8651279)]]], [[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]);
|
@ -1,3 +1,3 @@
|
||||
select polygonAreaCartesian([[[(0., 0.), (0., 5.), (5., 5.), (5., 0.)]]]);
|
||||
select polygonAreaGeographic([[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]);
|
||||
select polygonAreaSpherical([[[(4.346693, 50.858306), (4.367945, 50.852455), (4.366227, 50.840809), (4.344961, 50.833264), (4.338074, 50.848677), (4.346693, 50.858306)]]]);
|
||||
SELECT polygonAreaCartesian([]); -- { serverError 36 }
|
@ -7,12 +7,12 @@ CURDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
${CLICKHOUSE_CLIENT} -q "drop table if exists country_polygons;"
|
||||
${CLICKHOUSE_CLIENT} -q "create table country_polygons(name String, p Array(Array(Tuple(Float64, Float64)))) engine=MergeTree() order by tuple();"
|
||||
cat ${CURDIR}/country_polygons.tsv | ${CLICKHOUSE_CLIENT} -q "insert into country_polygons format TSV"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT c, d, polygonsIntersectionGeographic(a, b) FROM (SELECT first.p AS a, second.p AS b, first.name AS c, second.name AS d FROM country_polygons AS first CROSS JOIN country_polygons AS second LIMIT 100) format TSV"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT c, d, polygonsIntersectionSpherical(a, b) FROM (SELECT first.p AS a, second.p AS b, first.name AS c, second.name AS d FROM country_polygons AS first CROSS JOIN country_polygons AS second LIMIT 100) format TSV"
|
||||
${CLICKHOUSE_CLIENT} -q "drop table if exists country_polygons;"
|
||||
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "drop table if exists country_rings;"
|
||||
${CLICKHOUSE_CLIENT} -q "create table country_rings(name String, p Array(Tuple(Float64, Float64))) engine=MergeTree() order by tuple();"
|
||||
cat ${CURDIR}/country_rings.tsv | ${CLICKHOUSE_CLIENT} -q "insert into country_rings format TSV"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT c, d, polygonsIntersectionGeographic(a, b) FROM (SELECT first.p AS a, second.p AS b, first.name AS c, second.name AS d FROM country_rings AS first CROSS JOIN country_rings AS second LIMIT 100) format TSV"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT c, d, polygonsIntersectionSpherical(a, b) FROM (SELECT first.p AS a, second.p AS b, first.name AS c, second.name AS d FROM country_rings AS first CROSS JOIN country_rings AS second LIMIT 100) format TSV"
|
||||
${CLICKHOUSE_CLIENT} -q "drop table if exists country_rings;"
|
@ -8,9 +8,9 @@ ${CLICKHOUSE_CLIENT} -q "drop table if exists country_polygons;"
|
||||
${CLICKHOUSE_CLIENT} -q "create table country_polygons(name String, p Array(Array(Tuple(Float64, Float64)))) engine=MergeTree() order by tuple();"
|
||||
cat ${CURDIR}/country_polygons.tsv | ${CLICKHOUSE_CLIENT} -q "insert into country_polygons format TSV"
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT name, polygonPerimeterGeographic(p) from country_polygons"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT name, polygonPerimeterSpherical(p) from country_polygons"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT '-------------------------------------'"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT name, polygonAreaGeographic(p) from country_polygons"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT name, polygonAreaSpherical(p) from country_polygons"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT '-------------------------------------'"
|
||||
${CLICKHOUSE_CLIENT} -q "drop table if exists country_rings;"
|
||||
|
||||
@ -18,8 +18,8 @@ ${CLICKHOUSE_CLIENT} -q "drop table if exists country_rings;"
|
||||
${CLICKHOUSE_CLIENT} -q "create table country_rings(name String, p Array(Tuple(Float64, Float64))) engine=MergeTree() order by tuple();"
|
||||
cat ${CURDIR}/country_rings.tsv | ${CLICKHOUSE_CLIENT} -q "insert into country_rings format TSV"
|
||||
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT name, polygonPerimeterGeographic(p) from country_rings"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT name, polygonPerimeterSpherical(p) from country_rings"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT '-------------------------------------'"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT name, polygonAreaGeographic(p) from country_rings"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT name, polygonAreaSpherical(p) from country_rings"
|
||||
${CLICKHOUSE_CLIENT} -q "SELECT '-------------------------------------'"
|
||||
${CLICKHOUSE_CLIENT} -q "drop table if exists country_rings;"
|
Loading…
Reference in New Issue
Block a user