[feature](GEO)Support read/write WKB/EWKB to gis types (#18526)
Support mutual conversion from wkb and gis types.also compatible with EWKB format https://cwiki.apache.org/confluence/display/DORIS/DSIP-033%3A+More+GEO+functions
This commit is contained in:
89
be/src/geo/ByteOrderDataInStream.h
Normal file
89
be/src/geo/ByteOrderDataInStream.h
Normal file
@ -0,0 +1,89 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
#include "ByteOrderValues.h"
|
||||
#include "geo/geo_common.h"
|
||||
#include "machine.h"
|
||||
namespace doris {
|
||||
class ByteOrderDataInStream {
|
||||
public:
|
||||
ByteOrderDataInStream() : ByteOrderDataInStream(nullptr, 0) {};
|
||||
|
||||
ByteOrderDataInStream(const unsigned char* buff, size_t buffsz)
|
||||
: byteOrder(getMachineByteOrder()), buf(buff), end(buff + buffsz) {};
|
||||
|
||||
~ByteOrderDataInStream() = default;
|
||||
|
||||
void setOrder(int order) { byteOrder = order; };
|
||||
|
||||
unsigned char readByte() {
|
||||
if (size() < 1) {
|
||||
return GEO_PARSE_WKB_SYNTAX_ERROR;
|
||||
}
|
||||
auto ret = buf[0];
|
||||
buf++;
|
||||
return ret;
|
||||
};
|
||||
|
||||
int32_t readInt() {
|
||||
if (size() < 4) {
|
||||
return GEO_PARSE_WKB_SYNTAX_ERROR;
|
||||
}
|
||||
auto ret = ByteOrderValues::getInt(buf, byteOrder);
|
||||
buf += 4;
|
||||
return ret;
|
||||
};
|
||||
|
||||
uint32_t readUnsigned() {
|
||||
if (size() < 4) {
|
||||
return GEO_PARSE_WKB_SYNTAX_ERROR;
|
||||
}
|
||||
auto ret = ByteOrderValues::getUnsigned(buf, byteOrder);
|
||||
buf += 4;
|
||||
return ret;
|
||||
};
|
||||
|
||||
int64_t readLong() {
|
||||
if (size() < 8) {
|
||||
return GEO_PARSE_WKB_SYNTAX_ERROR;
|
||||
}
|
||||
|
||||
auto ret = ByteOrderValues::getLong(buf, byteOrder);
|
||||
buf += 8;
|
||||
return ret;
|
||||
};
|
||||
|
||||
double readDouble() {
|
||||
if (size() < 8) {
|
||||
return GEO_PARSE_WKB_SYNTAX_ERROR;
|
||||
}
|
||||
auto ret = ByteOrderValues::getDouble(buf, byteOrder);
|
||||
buf += 8;
|
||||
return ret;
|
||||
};
|
||||
|
||||
size_t size() const { return static_cast<size_t>(end - buf); };
|
||||
|
||||
private:
|
||||
int byteOrder;
|
||||
const unsigned char* buf;
|
||||
const unsigned char* end;
|
||||
};
|
||||
|
||||
} // namespace doris
|
||||
122
be/src/geo/ByteOrderValues.cpp
Normal file
122
be/src/geo/ByteOrderValues.cpp
Normal file
@ -0,0 +1,122 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "ByteOrderValues.h"
|
||||
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
|
||||
namespace doris {
|
||||
|
||||
int32_t ByteOrderValues::getInt(const unsigned char* buf, int byteOrder) {
|
||||
if (byteOrder == ENDIAN_BIG) {
|
||||
return ((int32_t)(buf[0] & 0xff) << 24) | ((int32_t)(buf[1] & 0xff) << 16) |
|
||||
((int32_t)(buf[2] & 0xff) << 8) | ((int32_t)(buf[3] & 0xff));
|
||||
} else { // ENDIAN_LITTLE
|
||||
return ((int32_t)(buf[3] & 0xff) << 24) | ((int32_t)(buf[2] & 0xff) << 16) |
|
||||
((int32_t)(buf[1] & 0xff) << 8) | ((int32_t)(buf[0] & 0xff));
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t ByteOrderValues::getUnsigned(const unsigned char* buf, int byteOrder) {
|
||||
if (byteOrder == ENDIAN_BIG) {
|
||||
return ((uint32_t)(buf[0] & 0xff) << 24) | ((uint32_t)(buf[1] & 0xff) << 16) |
|
||||
((uint32_t)(buf[2] & 0xff) << 8) | ((uint32_t)(buf[3] & 0xff));
|
||||
} else { // ENDIAN_LITTLE
|
||||
return ((uint32_t)(buf[3] & 0xff) << 24) | ((uint32_t)(buf[2] & 0xff) << 16) |
|
||||
((uint32_t)(buf[1] & 0xff) << 8) | ((uint32_t)(buf[0] & 0xff));
|
||||
}
|
||||
}
|
||||
|
||||
void ByteOrderValues::putInt(int32_t intValue, unsigned char* buf, int byteOrder) {
|
||||
if (byteOrder == ENDIAN_BIG) {
|
||||
buf[0] = (unsigned char)(intValue >> 24);
|
||||
buf[1] = (unsigned char)(intValue >> 16);
|
||||
buf[2] = (unsigned char)(intValue >> 8);
|
||||
buf[3] = (unsigned char)intValue;
|
||||
} else { // ENDIAN_LITTLE
|
||||
buf[3] = (unsigned char)(intValue >> 24);
|
||||
buf[2] = (unsigned char)(intValue >> 16);
|
||||
buf[1] = (unsigned char)(intValue >> 8);
|
||||
buf[0] = (unsigned char)intValue;
|
||||
}
|
||||
}
|
||||
|
||||
void ByteOrderValues::putUnsigned(uint32_t intValue, unsigned char* buf, int byteOrder) {
|
||||
if (byteOrder == ENDIAN_BIG) {
|
||||
buf[0] = (unsigned char)(intValue >> 24);
|
||||
buf[1] = (unsigned char)(intValue >> 16);
|
||||
buf[2] = (unsigned char)(intValue >> 8);
|
||||
buf[3] = (unsigned char)intValue;
|
||||
} else { // ENDIAN_LITTLE
|
||||
buf[3] = (unsigned char)(intValue >> 24);
|
||||
buf[2] = (unsigned char)(intValue >> 16);
|
||||
buf[1] = (unsigned char)(intValue >> 8);
|
||||
buf[0] = (unsigned char)intValue;
|
||||
}
|
||||
}
|
||||
|
||||
int64_t ByteOrderValues::getLong(const unsigned char* buf, int byteOrder) {
|
||||
if (byteOrder == ENDIAN_BIG) {
|
||||
return (int64_t)(buf[0]) << 56 | (int64_t)(buf[1] & 0xff) << 48 |
|
||||
(int64_t)(buf[2] & 0xff) << 40 | (int64_t)(buf[3] & 0xff) << 32 |
|
||||
(int64_t)(buf[4] & 0xff) << 24 | (int64_t)(buf[5] & 0xff) << 16 |
|
||||
(int64_t)(buf[6] & 0xff) << 8 | (int64_t)(buf[7] & 0xff);
|
||||
} else { // ENDIAN_LITTLE
|
||||
return (int64_t)(buf[7]) << 56 | (int64_t)(buf[6] & 0xff) << 48 |
|
||||
(int64_t)(buf[5] & 0xff) << 40 | (int64_t)(buf[4] & 0xff) << 32 |
|
||||
(int64_t)(buf[3] & 0xff) << 24 | (int64_t)(buf[2] & 0xff) << 16 |
|
||||
(int64_t)(buf[1] & 0xff) << 8 | (int64_t)(buf[0] & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
void ByteOrderValues::putLong(int64_t longValue, unsigned char* buf, int byteOrder) {
|
||||
if (byteOrder == ENDIAN_BIG) {
|
||||
buf[0] = (unsigned char)(longValue >> 56);
|
||||
buf[1] = (unsigned char)(longValue >> 48);
|
||||
buf[2] = (unsigned char)(longValue >> 40);
|
||||
buf[3] = (unsigned char)(longValue >> 32);
|
||||
buf[4] = (unsigned char)(longValue >> 24);
|
||||
buf[5] = (unsigned char)(longValue >> 16);
|
||||
buf[6] = (unsigned char)(longValue >> 8);
|
||||
buf[7] = (unsigned char)longValue;
|
||||
} else { // ENDIAN_LITTLE
|
||||
buf[0] = (unsigned char)longValue;
|
||||
buf[1] = (unsigned char)(longValue >> 8);
|
||||
buf[2] = (unsigned char)(longValue >> 16);
|
||||
buf[3] = (unsigned char)(longValue >> 24);
|
||||
buf[4] = (unsigned char)(longValue >> 32);
|
||||
buf[5] = (unsigned char)(longValue >> 40);
|
||||
buf[6] = (unsigned char)(longValue >> 48);
|
||||
buf[7] = (unsigned char)(longValue >> 56);
|
||||
}
|
||||
}
|
||||
|
||||
double ByteOrderValues::getDouble(const unsigned char* buf, int byteOrder) {
|
||||
int64_t longValue = getLong(buf, byteOrder);
|
||||
double ret;
|
||||
std::memcpy(&ret, &longValue, sizeof(double));
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ByteOrderValues::putDouble(double doubleValue, unsigned char* buf, int byteOrder) {
|
||||
int64_t longValue;
|
||||
std::memcpy(&longValue, &doubleValue, sizeof(double));
|
||||
putLong(longValue, buf, byteOrder);
|
||||
}
|
||||
|
||||
} // namespace doris
|
||||
49
be/src/geo/ByteOrderValues.h
Normal file
49
be/src/geo/ByteOrderValues.h
Normal file
@ -0,0 +1,49 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include <ctime>
|
||||
using int64_t = __int64_t;
|
||||
using int32_t = __int32_t;
|
||||
using uint32_t = __uint32_t;
|
||||
|
||||
namespace doris {
|
||||
|
||||
/**
|
||||
* \class ByteOrderValues
|
||||
*
|
||||
* \brief Methods to read and write primitive datatypes from/to byte
|
||||
* sequences, allowing the byte order to be specified.
|
||||
*
|
||||
*/
|
||||
class ByteOrderValues {
|
||||
public:
|
||||
enum EndianType { ENDIAN_BIG = 0, ENDIAN_LITTLE = 1 };
|
||||
|
||||
static int32_t getInt(const unsigned char* buf, int byteOrder);
|
||||
static void putInt(int32_t intValue, unsigned char* buf, int byteOrder);
|
||||
|
||||
static uint32_t getUnsigned(const unsigned char* buf, int byteOrder);
|
||||
static void putUnsigned(uint32_t intValue, unsigned char* buf, int byteOrder);
|
||||
|
||||
static int64_t getLong(const unsigned char* buf, int byteOrder);
|
||||
static void putLong(int64_t longValue, unsigned char* buf, int byteOrder);
|
||||
|
||||
static double getDouble(const unsigned char* buf, int byteOrder);
|
||||
static void putDouble(double doubleValue, unsigned char* buf, int byteOrder);
|
||||
};
|
||||
|
||||
} // namespace doris
|
||||
@ -25,9 +25,12 @@ add_library(Geo STATIC
|
||||
geo_common.cpp
|
||||
geo_types.cpp
|
||||
wkt_parse.cpp
|
||||
wkb_parse.cpp
|
||||
${GENSRC_DIR}/geo/wkt_lex.l.cpp
|
||||
${GENSRC_DIR}/geo/wkt_yacc.y.cpp
|
||||
)
|
||||
geo_tobinary.cpp
|
||||
ByteOrderValues.cpp
|
||||
machine.h)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
set(WARNING_OPTION "-Wno-unused-but-set-variable")
|
||||
|
||||
@ -44,6 +44,7 @@ enum GeoParseStatus {
|
||||
GEO_PARSE_POLYLINE_INVALID = 7,
|
||||
GEO_PARSE_CIRCLE_INVALID = 8,
|
||||
GEO_PARSE_WKT_SYNTAX_ERROR = 9,
|
||||
GEO_PARSE_WKB_SYNTAX_ERROR = 10,
|
||||
};
|
||||
|
||||
std::string to_string(GeoParseStatus status);
|
||||
|
||||
141
be/src/geo/geo_tobinary.cpp
Normal file
141
be/src/geo/geo_tobinary.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "geo_tobinary.h"
|
||||
|
||||
#include "geo_tobinary_type.h"
|
||||
#include "geo_types.h"
|
||||
#include "sstream"
|
||||
#include "wkb_parse.h"
|
||||
|
||||
namespace doris {
|
||||
|
||||
bool toBinary::geo_tobinary(GeoShape* shape, bool isEwkb, std::string* result) {
|
||||
ToBinaryContext ctx;
|
||||
std::stringstream result_stream;
|
||||
ctx.outStream = &result_stream;
|
||||
ctx.isEwkb = isEwkb;
|
||||
if (toBinary::write(shape, &ctx)) {
|
||||
*result = result_stream.str();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool toBinary::write(GeoShape* shape, ToBinaryContext* ctx) {
|
||||
switch (shape->type()) {
|
||||
case GEO_SHAPE_POINT: {
|
||||
return writeGeoPoint((GeoPoint*)(shape), ctx);
|
||||
}
|
||||
case GEO_SHAPE_LINE_STRING: {
|
||||
return writeGeoLine((GeoLine*)(shape), ctx);
|
||||
}
|
||||
case GEO_SHAPE_POLYGON: {
|
||||
return writeGeoPolygon((GeoPolygon*)(shape), ctx);
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool toBinary::writeGeoPoint(GeoPoint* point, ToBinaryContext* ctx) {
|
||||
writeByteOrder(ctx);
|
||||
writeGeometryType(wkbType::wkbPoint, ctx);
|
||||
if (ctx->isEwkb) {
|
||||
writeSRID(ctx);
|
||||
}
|
||||
GeoCoordinateList p = point->to_coords();
|
||||
|
||||
writeCoordinateList(p, false, ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool toBinary::writeGeoLine(GeoLine* line, ToBinaryContext* ctx) {
|
||||
writeByteOrder(ctx);
|
||||
writeGeometryType(wkbType::wkbLine, ctx);
|
||||
if (ctx->isEwkb) {
|
||||
writeSRID(ctx);
|
||||
}
|
||||
GeoCoordinateList p = line->to_coords();
|
||||
|
||||
writeCoordinateList(p, true, ctx);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool toBinary::writeGeoPolygon(doris::GeoPolygon* polygon, ToBinaryContext* ctx) {
|
||||
writeByteOrder(ctx);
|
||||
writeGeometryType(wkbType::wkbPolygon, ctx);
|
||||
if (ctx->isEwkb) {
|
||||
writeSRID(ctx);
|
||||
}
|
||||
writeInt(polygon->numLoops(), ctx);
|
||||
GeoCoordinateListList* coordss = polygon->to_coords();
|
||||
|
||||
for (int i = 0; i < coordss->list.size(); ++i) {
|
||||
writeCoordinateList(*coordss->list[i], true, ctx);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void toBinary::writeByteOrder(ToBinaryContext* ctx) {
|
||||
ctx->byteOrder = getMachineByteOrder();
|
||||
if (ctx->byteOrder == 1) {
|
||||
ctx->buf[0] = byteOrder::wkbNDR;
|
||||
} else {
|
||||
ctx->buf[0] = byteOrder::wkbXDR;
|
||||
}
|
||||
|
||||
ctx->outStream->write(reinterpret_cast<char*>(ctx->buf), 1);
|
||||
}
|
||||
|
||||
void toBinary::writeGeometryType(int typeId, ToBinaryContext* ctx) {
|
||||
if (ctx->isEwkb) {
|
||||
typeId |= 0x20000000;
|
||||
}
|
||||
writeInt(typeId, ctx);
|
||||
}
|
||||
|
||||
void toBinary::writeInt(int val, ToBinaryContext* ctx) {
|
||||
ByteOrderValues::putInt(val, ctx->buf, ctx->byteOrder);
|
||||
ctx->outStream->write(reinterpret_cast<char*>(ctx->buf), 4);
|
||||
}
|
||||
|
||||
void toBinary::writeSRID(ToBinaryContext* ctx) {
|
||||
writeInt(SRID, ctx);
|
||||
}
|
||||
|
||||
void toBinary::writeCoordinateList(const GeoCoordinateList& coords, bool sized,
|
||||
ToBinaryContext* ctx) {
|
||||
std::size_t size = coords.list.size();
|
||||
|
||||
if (sized) {
|
||||
writeInt(static_cast<int>(size), ctx);
|
||||
}
|
||||
for (std::size_t i = 0; i < size; i++) {
|
||||
GeoCoordinate coord = coords.list[i];
|
||||
writeCoordinate(coord, ctx);
|
||||
}
|
||||
}
|
||||
|
||||
void toBinary::writeCoordinate(GeoCoordinate& coords, ToBinaryContext* ctx) {
|
||||
ByteOrderValues::putDouble(coords.x, ctx->buf, ctx->byteOrder);
|
||||
ctx->outStream->write(reinterpret_cast<char*>(ctx->buf), 8);
|
||||
ByteOrderValues::putDouble(coords.y, ctx->buf, ctx->byteOrder);
|
||||
ctx->outStream->write(reinterpret_cast<char*>(ctx->buf), 8);
|
||||
}
|
||||
|
||||
} // namespace doris
|
||||
58
be/src/geo/geo_tobinary.h
Normal file
58
be/src/geo/geo_tobinary.h
Normal file
@ -0,0 +1,58 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
//#include "geo_types.h"
|
||||
|
||||
#include "geo/geo_common.h"
|
||||
#include "geo/geo_tobinary_type.h"
|
||||
#include "geo/wkt_parse_type.h"
|
||||
|
||||
namespace doris {
|
||||
|
||||
class GeoShape;
|
||||
class GeoPoint;
|
||||
class GeoLine;
|
||||
class GeoPolygon;
|
||||
|
||||
class toBinary {
|
||||
public:
|
||||
static bool geo_tobinary(GeoShape* shape, bool isEwkb, std::string* result);
|
||||
|
||||
static bool write(GeoShape* shape, ToBinaryContext* ctx);
|
||||
|
||||
private:
|
||||
static bool writeGeoPoint(GeoPoint* point, ToBinaryContext* ctx);
|
||||
|
||||
static bool writeGeoLine(GeoLine* line, ToBinaryContext* ctx);
|
||||
|
||||
static bool writeGeoPolygon(GeoPolygon* polygon, ToBinaryContext* ctx);
|
||||
|
||||
static void writeByteOrder(ToBinaryContext* ctx);
|
||||
|
||||
static void writeGeometryType(int geometryType, ToBinaryContext* ctx);
|
||||
|
||||
static void writeInt(int intValue, ToBinaryContext* ctx);
|
||||
|
||||
static void writeSRID(ToBinaryContext* ctx);
|
||||
|
||||
static void writeCoordinateList(const GeoCoordinateList& coords, bool sized,
|
||||
ToBinaryContext* ctx);
|
||||
|
||||
static void writeCoordinate(GeoCoordinate& coords, ToBinaryContext* ctx);
|
||||
};
|
||||
|
||||
} // namespace doris
|
||||
47
be/src/geo/geo_tobinary_type.h
Normal file
47
be/src/geo/geo_tobinary_type.h
Normal file
@ -0,0 +1,47 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
#pragma once
|
||||
#include <memory>
|
||||
|
||||
namespace doris {
|
||||
|
||||
enum byteOrder { wkbXDR = 0, wkbNDR = 1 };
|
||||
|
||||
enum wkbType {
|
||||
wkbPoint = 1,
|
||||
wkbLine = 2,
|
||||
wkbPolygon = 3,
|
||||
wkbMultiPoint = 4,
|
||||
wkbMultiLineString = 5,
|
||||
wkbMultiPolygon = 6,
|
||||
wkbGeometryCollection = 7
|
||||
};
|
||||
|
||||
const int SRID = 4326;
|
||||
|
||||
} // namespace doris
|
||||
|
||||
struct ToBinaryContext {
|
||||
// WKBConstants::wkbwkbXDR | WKBConstants::wkbNDR
|
||||
int byteOrder;
|
||||
//Ewkb format:true | false
|
||||
bool isEwkb;
|
||||
|
||||
unsigned char buf[8];
|
||||
|
||||
std::ostream* outStream;
|
||||
};
|
||||
@ -31,6 +31,8 @@
|
||||
#include <sstream>
|
||||
#include <type_traits>
|
||||
|
||||
#include "geo/geo_tobinary.h"
|
||||
#include "geo/wkb_parse.h"
|
||||
#include "geo/wkt_parse.h"
|
||||
|
||||
namespace doris {
|
||||
@ -189,6 +191,30 @@ GeoShape* GeoShape::from_wkt(const char* data, size_t size, GeoParseStatus* stat
|
||||
return shape;
|
||||
}
|
||||
|
||||
GeoShape* GeoShape::from_wkb(const char* data, size_t size, GeoParseStatus* status) {
|
||||
std::stringstream wkb;
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
wkb << *data;
|
||||
data++;
|
||||
}
|
||||
GeoShape* shape = nullptr;
|
||||
*status = WkbParse::parse_wkb(wkb, false, &shape);
|
||||
return shape;
|
||||
}
|
||||
|
||||
GeoShape* GeoShape::from_ewkb(const char* data, size_t size, GeoParseStatus* status) {
|
||||
std::stringstream ewkb;
|
||||
|
||||
for (int i = 0; i < size; ++i) {
|
||||
ewkb << *data;
|
||||
data++;
|
||||
}
|
||||
GeoShape* shape = nullptr;
|
||||
*status = WkbParse::parse_wkb(ewkb, true, &shape);
|
||||
return shape;
|
||||
}
|
||||
|
||||
GeoShape* GeoShape::from_encoded(const void* ptr, size_t size) {
|
||||
if (size < 2 || ((const char*)ptr)[0] != 0X00) {
|
||||
return nullptr;
|
||||
@ -229,6 +255,47 @@ GeoParseStatus GeoPoint::from_coord(const GeoCoordinate& coord) {
|
||||
return to_s2point(coord, _point.get());
|
||||
}
|
||||
|
||||
GeoCoordinateList GeoPoint::to_coords() const {
|
||||
GeoCoordinate coord;
|
||||
coord.x = GeoPoint::x();
|
||||
coord.y = GeoPoint::y();
|
||||
GeoCoordinateList coords;
|
||||
coords.add(coord);
|
||||
return coords;
|
||||
}
|
||||
|
||||
GeoCoordinateList GeoLine::to_coords() const {
|
||||
GeoCoordinateList coords;
|
||||
for (int i = 0; i < GeoLine::numPoint(); ++i) {
|
||||
GeoCoordinate coord;
|
||||
coord.x = S2LatLng(*GeoLine::getPoint(i)).lng().degrees();
|
||||
coord.y = S2LatLng(*GeoLine::getPoint(i)).lat().degrees();
|
||||
coords.add(coord);
|
||||
}
|
||||
return coords;
|
||||
}
|
||||
|
||||
GeoCoordinateListList* GeoPolygon::to_coords() const {
|
||||
GeoCoordinateListList* coordss = new GeoCoordinateListList();
|
||||
for (int i = 0; i < GeoPolygon::numLoops(); ++i) {
|
||||
GeoCoordinateList* coords = new GeoCoordinateList();
|
||||
S2Loop* loop = GeoPolygon::getLoop(i);
|
||||
for (int j = 0; j < loop->num_vertices(); ++j) {
|
||||
GeoCoordinate coord;
|
||||
coord.x = S2LatLng(loop->vertex(j)).lng().degrees();
|
||||
coord.y = S2LatLng(loop->vertex(j)).lat().degrees();
|
||||
coords->add(coord);
|
||||
if (j == loop->num_vertices() - 1) {
|
||||
coord.x = S2LatLng(loop->vertex(0)).lng().degrees();
|
||||
coord.y = S2LatLng(loop->vertex(0)).lat().degrees();
|
||||
coords->add(coord);
|
||||
}
|
||||
}
|
||||
coordss->add(coords);
|
||||
}
|
||||
return coordss;
|
||||
}
|
||||
|
||||
std::string GeoPoint::to_string() const {
|
||||
return as_wkt();
|
||||
}
|
||||
@ -343,6 +410,14 @@ bool GeoLine::decode(const void* data, size_t size) {
|
||||
return _polyline->Decode(&decoder);
|
||||
}
|
||||
|
||||
int GeoLine::numPoint() const {
|
||||
return _polyline->num_vertices();
|
||||
}
|
||||
|
||||
S2Point* GeoLine::getPoint(int i) const {
|
||||
return const_cast<S2Point*>(&(_polyline->vertex(i)));
|
||||
}
|
||||
|
||||
GeoParseStatus GeoPolygon::from_coords(const GeoCoordinateListList& list) {
|
||||
return to_s2polygon(list, &_polygon);
|
||||
}
|
||||
@ -419,6 +494,14 @@ std::double_t GeoPolygon::getArea() const {
|
||||
return _polygon->GetArea();
|
||||
}
|
||||
|
||||
int GeoPolygon::numLoops() const {
|
||||
return _polygon->num_loops();
|
||||
}
|
||||
|
||||
S2Loop* GeoPolygon::getLoop(int i) const {
|
||||
return const_cast<S2Loop*>(_polygon->loop(i));
|
||||
}
|
||||
|
||||
GeoParseStatus GeoCircle::init(double lng, double lat, double radius_meter) {
|
||||
S2Point center;
|
||||
auto status = to_s2point(lng, lat, ¢er);
|
||||
@ -504,4 +587,20 @@ bool GeoShape::ComputeArea(GeoShape* rhs, double* area, std::string square_unit)
|
||||
}
|
||||
}
|
||||
|
||||
std::string GeoShape::as_binary(GeoShape* rhs) {
|
||||
std::string res;
|
||||
if (toBinary::geo_tobinary(rhs, false, &res)) {
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string GeoShape::as_ewkb(doris::GeoShape* rhs) {
|
||||
std::string res;
|
||||
if (toBinary::geo_tobinary(rhs, true, &res)) {
|
||||
return res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
} // namespace doris
|
||||
|
||||
@ -27,6 +27,7 @@
|
||||
class S2Polyline;
|
||||
class S2Polygon;
|
||||
class S2Cap;
|
||||
class S2Loop;
|
||||
|
||||
template <typename T>
|
||||
class Vector3;
|
||||
@ -50,6 +51,9 @@ public:
|
||||
// return nullptr if convert failed, and reason will be set in status
|
||||
static GeoShape* from_wkt(const char* data, size_t size, GeoParseStatus* status);
|
||||
|
||||
static GeoShape* from_wkb(const char* data, size_t size, GeoParseStatus* status);
|
||||
static GeoShape* from_ewkb(const char* data, size_t size, GeoParseStatus* status);
|
||||
|
||||
void encode_to(std::string* buf);
|
||||
bool decode_from(const void* data, size_t size);
|
||||
|
||||
@ -57,6 +61,8 @@ public:
|
||||
|
||||
virtual bool contains(const GeoShape* rhs) const { return false; }
|
||||
virtual std::string to_string() const { return ""; }
|
||||
static std::string as_binary(GeoShape* rhs);
|
||||
static std::string as_ewkb(GeoShape* rhs);
|
||||
|
||||
static bool ComputeArea(GeoShape* rhs, double* angle, std::string square_unit);
|
||||
|
||||
@ -73,6 +79,8 @@ public:
|
||||
GeoParseStatus from_coord(double x, double y);
|
||||
GeoParseStatus from_coord(const GeoCoordinate& point);
|
||||
|
||||
GeoCoordinateList to_coords() const;
|
||||
|
||||
GeoShapeType type() const override { return GEO_SHAPE_POINT; }
|
||||
|
||||
const S2Point* point() const { return _point.get(); }
|
||||
@ -106,11 +114,16 @@ public:
|
||||
|
||||
GeoParseStatus from_coords(const GeoCoordinateList& list);
|
||||
|
||||
GeoCoordinateList to_coords() const;
|
||||
|
||||
GeoShapeType type() const override { return GEO_SHAPE_LINE_STRING; }
|
||||
const S2Polyline* polyline() const { return _polyline.get(); }
|
||||
|
||||
std::string as_wkt() const override;
|
||||
|
||||
int numPoint() const;
|
||||
S2Point* getPoint(int i) const;
|
||||
|
||||
protected:
|
||||
void encode(std::string* buf) override;
|
||||
bool decode(const void* data, size_t size) override;
|
||||
@ -125,6 +138,7 @@ public:
|
||||
~GeoPolygon() override;
|
||||
|
||||
GeoParseStatus from_coords(const GeoCoordinateListList& list);
|
||||
GeoCoordinateListList* to_coords() const;
|
||||
|
||||
GeoShapeType type() const override { return GEO_SHAPE_POLYGON; }
|
||||
const S2Polygon* polygon() const { return _polygon.get(); }
|
||||
@ -132,7 +146,9 @@ public:
|
||||
bool contains(const GeoShape* rhs) const override;
|
||||
std::string as_wkt() const override;
|
||||
|
||||
int numLoops() const;
|
||||
double getArea() const;
|
||||
S2Loop* getLoop(int i) const;
|
||||
|
||||
protected:
|
||||
void encode(std::string* buf) override;
|
||||
|
||||
27
be/src/geo/machine.h
Normal file
27
be/src/geo/machine.h
Normal file
@ -0,0 +1,27 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
namespace doris {
|
||||
/**
|
||||
* Check endianness of current machine.
|
||||
* @return 0 for big_endian | xdr; 1 == little_endian | ndr
|
||||
*/
|
||||
inline int getMachineByteOrder() {
|
||||
static int endian_check = 1; // don't modify !!
|
||||
return *((char*)&endian_check);
|
||||
}
|
||||
} // namespace doris
|
||||
197
be/src/geo/wkb_parse.cpp
Normal file
197
be/src/geo/wkb_parse.cpp
Normal file
@ -0,0 +1,197 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "wkb_parse.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "geo_tobinary_type.h"
|
||||
#include "sstream"
|
||||
|
||||
namespace doris {
|
||||
|
||||
GeoParseStatus WkbParse::parse_wkb(std::istream& is, bool isEwkb, GeoShape** shape) {
|
||||
WkbParseContext ctx;
|
||||
|
||||
ctx.isEwkb = isEwkb;
|
||||
ctx = *(WkbParse::read(is, &ctx));
|
||||
if (ctx.parse_status == GEO_PARSE_OK) {
|
||||
*shape = ctx.shape;
|
||||
} else {
|
||||
ctx.parse_status = GEO_PARSE_WKT_SYNTAX_ERROR;
|
||||
}
|
||||
return ctx.parse_status;
|
||||
}
|
||||
|
||||
WkbParseContext* WkbParse::read(std::istream& is, WkbParseContext* ctx) {
|
||||
is.seekg(0, std::ios::end);
|
||||
auto size = is.tellg();
|
||||
is.seekg(0, std::ios::beg);
|
||||
|
||||
std::vector<unsigned char> buf(static_cast<size_t>(size));
|
||||
is.read(reinterpret_cast<char*>(buf.data()), static_cast<std::streamsize>(size));
|
||||
|
||||
ctx->dis = ByteOrderDataInStream(buf.data(), buf.size()); // will default to machine endian
|
||||
|
||||
ctx->shape = readGeometry(ctx);
|
||||
|
||||
if (!ctx->shape) {
|
||||
ctx->parse_status = GEO_PARSE_WKB_SYNTAX_ERROR;
|
||||
}
|
||||
return ctx;
|
||||
}
|
||||
|
||||
GeoShape* WkbParse::readGeometry(WkbParseContext* ctx) {
|
||||
// determine byte order
|
||||
unsigned char byteOrder = ctx->dis.readByte();
|
||||
|
||||
// default is machine endian
|
||||
if (byteOrder == byteOrder::wkbNDR) {
|
||||
ctx->dis.setOrder(ByteOrderValues::ENDIAN_LITTLE);
|
||||
} else if (byteOrder == byteOrder::wkbXDR) {
|
||||
ctx->dis.setOrder(ByteOrderValues::ENDIAN_BIG);
|
||||
}
|
||||
|
||||
uint32_t typeInt = ctx->dis.readUnsigned();
|
||||
|
||||
uint32_t geometryType = (typeInt & 0xffff) % 1000;
|
||||
|
||||
bool hasSRID = ((typeInt & 0x20000000) != 0);
|
||||
|
||||
if (ctx->isEwkb) {
|
||||
if (!hasSRID) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ctx->srid = ctx->dis.readInt(); // read SRID
|
||||
if (ctx->srid != 4326) {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ctx->isEwkb && hasSRID) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
GeoShape* shape;
|
||||
|
||||
switch (geometryType) {
|
||||
case wkbType::wkbPoint:
|
||||
shape = readPoint(ctx);
|
||||
break;
|
||||
case wkbType::wkbLine:
|
||||
shape = readLine(ctx);
|
||||
break;
|
||||
case wkbType::wkbPolygon:
|
||||
shape = readPolygon(ctx);
|
||||
break;
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
return shape;
|
||||
}
|
||||
|
||||
GeoPoint* WkbParse::readPoint(WkbParseContext* ctx) {
|
||||
GeoCoordinateList coords = WkbParse::readCoordinateList(1, ctx);
|
||||
GeoPoint* point = new GeoPoint();
|
||||
|
||||
if (point->from_coord(coords.list[0]) == GEO_PARSE_OK) {
|
||||
return point;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
GeoLine* WkbParse::readLine(WkbParseContext* ctx) {
|
||||
uint32_t size = ctx->dis.readUnsigned();
|
||||
minMemSize(wkbLine, size, ctx);
|
||||
|
||||
GeoCoordinateList coords = WkbParse::readCoordinateList(size, ctx);
|
||||
GeoLine* line = new GeoLine();
|
||||
|
||||
if (line->from_coords(coords) == GEO_PARSE_OK) {
|
||||
return line;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
GeoPolygon* WkbParse::readPolygon(WkbParseContext* ctx) {
|
||||
uint32_t num_loops = ctx->dis.readUnsigned();
|
||||
minMemSize(wkbPolygon, num_loops, ctx);
|
||||
GeoCoordinateListList coordss;
|
||||
for (int i = 0; i < num_loops; ++i) {
|
||||
uint32_t size = ctx->dis.readUnsigned();
|
||||
GeoCoordinateList* coords = new GeoCoordinateList();
|
||||
*coords = WkbParse::readCoordinateList(size, ctx);
|
||||
coordss.add(coords);
|
||||
}
|
||||
|
||||
GeoPolygon* polygon = new GeoPolygon();
|
||||
|
||||
if (polygon->from_coords(coordss) == GEO_PARSE_OK) {
|
||||
return polygon;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
GeoCoordinateList WkbParse::readCoordinateList(unsigned size, WkbParseContext* ctx) {
|
||||
GeoCoordinateList coords;
|
||||
for (uint32_t i = 0; i < size; i++) {
|
||||
readCoordinate(ctx);
|
||||
unsigned int j = 0;
|
||||
GeoCoordinate coord;
|
||||
coord.x = ctx->ordValues[j++];
|
||||
coord.y = ctx->ordValues[j++];
|
||||
coords.add(coord);
|
||||
}
|
||||
|
||||
return coords;
|
||||
}
|
||||
|
||||
GeoParseStatus WkbParse::minMemSize(int wkbType, uint64_t size, WkbParseContext* ctx) {
|
||||
uint64_t minSize = 0;
|
||||
constexpr uint64_t minCoordSize = 2 * sizeof(double);
|
||||
//constexpr uint64_t minPtSize = (1+4) + minCoordSize;
|
||||
//constexpr uint64_t minLineSize = (1+4+4); // empty line
|
||||
constexpr uint64_t minLoopSize = 4; // empty loop
|
||||
//constexpr uint64_t minPolySize = (1+4+4); // empty polygon
|
||||
//constexpr uint64_t minGeomSize = minLineSize;
|
||||
|
||||
switch (wkbType) {
|
||||
case wkbLine:
|
||||
minSize = size * minCoordSize;
|
||||
break;
|
||||
case wkbPolygon:
|
||||
minSize = size * minLoopSize;
|
||||
break;
|
||||
}
|
||||
if (ctx->dis.size() < minSize) {
|
||||
return GEO_PARSE_WKB_SYNTAX_ERROR;
|
||||
}
|
||||
return GEO_PARSE_OK;
|
||||
}
|
||||
bool WkbParse::readCoordinate(WkbParseContext* ctx) {
|
||||
for (std::size_t i = 0; i < ctx->inputDimension; ++i) {
|
||||
ctx->ordValues[i] = ctx->dis.readDouble();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace doris
|
||||
48
be/src/geo/wkb_parse.h
Normal file
48
be/src/geo/wkb_parse.h
Normal file
@ -0,0 +1,48 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#include "geo/geo_common.h"
|
||||
#include "geo/geo_types.h"
|
||||
#include "wkb_parse_ctx.h"
|
||||
|
||||
namespace doris {
|
||||
|
||||
class GeoShape;
|
||||
|
||||
class WkbParse {
|
||||
public:
|
||||
static GeoParseStatus parse_wkb(std::istream& is, bool isEwkb, GeoShape** shape);
|
||||
|
||||
static WkbParseContext* read(std::istream& is, WkbParseContext* ctx);
|
||||
|
||||
static GeoShape* readGeometry(WkbParseContext* ctx);
|
||||
|
||||
private:
|
||||
static GeoPoint* readPoint(WkbParseContext* ctx);
|
||||
|
||||
static GeoLine* readLine(WkbParseContext* ctx);
|
||||
|
||||
static GeoPolygon* readPolygon(WkbParseContext* ctx);
|
||||
|
||||
static GeoCoordinateList readCoordinateList(unsigned size, WkbParseContext* ctx);
|
||||
|
||||
static GeoParseStatus minMemSize(int wkbType, uint64_t size, WkbParseContext* ctx);
|
||||
|
||||
static bool readCoordinate(WkbParseContext* ctx);
|
||||
};
|
||||
|
||||
} // namespace doris
|
||||
41
be/src/geo/wkb_parse_ctx.h
Normal file
41
be/src/geo/wkb_parse_ctx.h
Normal file
@ -0,0 +1,41 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ByteOrderDataInStream.h"
|
||||
#include "array"
|
||||
|
||||
namespace doris {
|
||||
class GeoShape;
|
||||
}
|
||||
|
||||
struct WkbParseContext {
|
||||
unsigned int inputDimension = 2;
|
||||
|
||||
doris::ByteOrderDataInStream dis;
|
||||
|
||||
std::array<double, 2> ordValues;
|
||||
|
||||
//Ewkb format:true | false
|
||||
bool isEwkb;
|
||||
|
||||
int srid;
|
||||
|
||||
doris::GeoShape* shape = nullptr;
|
||||
doris::GeoParseStatus parse_status = doris::GEO_PARSE_OK;
|
||||
};
|
||||
@ -567,6 +567,194 @@ struct StGeoFromText {
|
||||
}
|
||||
};
|
||||
|
||||
struct StGeometryFromWKB {
|
||||
static constexpr auto NAME = "st_geometryfromwkb";
|
||||
static constexpr GeoShapeType shape_type = GEO_SHAPE_ANY;
|
||||
};
|
||||
|
||||
struct StGeomFromWKB {
|
||||
static constexpr auto NAME = "st_geomfromwkb";
|
||||
static constexpr GeoShapeType shape_type = GEO_SHAPE_ANY;
|
||||
};
|
||||
|
||||
template <typename Impl>
|
||||
struct StGeoFromWkb {
|
||||
static constexpr auto NEED_CONTEXT = true;
|
||||
static constexpr auto NAME = Impl::NAME;
|
||||
static const size_t NUM_ARGS = 1;
|
||||
static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
|
||||
size_t result) {
|
||||
DCHECK_EQ(arguments.size(), 1);
|
||||
auto return_type = block.get_data_type(result);
|
||||
auto& geo = block.get_by_position(arguments[0]).column;
|
||||
|
||||
const auto size = geo->size();
|
||||
MutableColumnPtr res = return_type->create_column();
|
||||
|
||||
GeoParseStatus status;
|
||||
std::string buf;
|
||||
for (int row = 0; row < size; ++row) {
|
||||
auto value = geo->get_data_at(row);
|
||||
std::unique_ptr<GeoShape> shape(GeoShape::from_wkb(value.data, value.size, &status));
|
||||
if (shape == nullptr || status != GEO_PARSE_OK) {
|
||||
res->insert_data(nullptr, 0);
|
||||
continue;
|
||||
}
|
||||
buf.clear();
|
||||
shape->encode_to(&buf);
|
||||
res->insert_data(buf.data(), buf.size());
|
||||
}
|
||||
block.replace_by_position(result, std::move(res));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
static Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
static Status close(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
|
||||
return Status::OK();
|
||||
}
|
||||
};
|
||||
|
||||
struct StGeometryFromEWKB {
|
||||
static constexpr auto NAME = "st_geometryfromewkb";
|
||||
static constexpr GeoShapeType shape_type = GEO_SHAPE_ANY;
|
||||
};
|
||||
|
||||
struct StGeomFromEWKB {
|
||||
static constexpr auto NAME = "st_geomfromewkb";
|
||||
static constexpr GeoShapeType shape_type = GEO_SHAPE_ANY;
|
||||
};
|
||||
|
||||
template <typename Impl>
|
||||
struct StGeoFromEwkb {
|
||||
static constexpr auto NEED_CONTEXT = true;
|
||||
static constexpr auto NAME = Impl::NAME;
|
||||
static const size_t NUM_ARGS = 1;
|
||||
static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
|
||||
size_t result) {
|
||||
DCHECK_EQ(arguments.size(), 1);
|
||||
auto return_type = block.get_data_type(result);
|
||||
auto& geo = block.get_by_position(arguments[0]).column;
|
||||
|
||||
const auto size = geo->size();
|
||||
MutableColumnPtr res = return_type->create_column();
|
||||
|
||||
GeoParseStatus status;
|
||||
std::string buf;
|
||||
for (int row = 0; row < size; ++row) {
|
||||
auto value = geo->get_data_at(row);
|
||||
std::unique_ptr<GeoShape> shape(GeoShape::from_ewkb(value.data, value.size, &status));
|
||||
if (shape == nullptr || status != GEO_PARSE_OK) {
|
||||
res->insert_data(nullptr, 0);
|
||||
continue;
|
||||
}
|
||||
buf.clear();
|
||||
shape->encode_to(&buf);
|
||||
res->insert_data(buf.data(), buf.size());
|
||||
}
|
||||
block.replace_by_position(result, std::move(res));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
static Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
static Status close(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
|
||||
return Status::OK();
|
||||
}
|
||||
};
|
||||
|
||||
struct StAsBinary {
|
||||
static constexpr auto NEED_CONTEXT = true;
|
||||
static constexpr auto NAME = "st_asbinary";
|
||||
static const size_t NUM_ARGS = 1;
|
||||
static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
|
||||
size_t result) {
|
||||
DCHECK_EQ(arguments.size(), 1);
|
||||
auto return_type = block.get_data_type(result);
|
||||
MutableColumnPtr res = return_type->create_column();
|
||||
|
||||
auto col = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
|
||||
const auto size = col->size();
|
||||
|
||||
std::unique_ptr<GeoShape> shape;
|
||||
|
||||
for (int row = 0; row < size; ++row) {
|
||||
auto shape_value = col->get_data_at(row);
|
||||
shape.reset(GeoShape::from_encoded(shape_value.data, shape_value.size));
|
||||
if (shape == nullptr) {
|
||||
res->insert_data(nullptr, 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string binary = GeoShape::as_binary(shape.get());
|
||||
if (binary.empty()) {
|
||||
res->insert_data(nullptr, 0);
|
||||
continue;
|
||||
}
|
||||
res->insert_data(binary.data(), binary.size());
|
||||
}
|
||||
|
||||
block.replace_by_position(result, std::move(res));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
static Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
static Status close(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
|
||||
return Status::OK();
|
||||
}
|
||||
};
|
||||
|
||||
struct StAsEwkb {
|
||||
static constexpr auto NEED_CONTEXT = true;
|
||||
static constexpr auto NAME = "st_asewkb";
|
||||
static const size_t NUM_ARGS = 1;
|
||||
static Status execute(FunctionContext* context, Block& block, const ColumnNumbers& arguments,
|
||||
size_t result) {
|
||||
DCHECK_EQ(arguments.size(), 1);
|
||||
auto return_type = block.get_data_type(result);
|
||||
MutableColumnPtr res = return_type->create_column();
|
||||
|
||||
auto col = block.get_by_position(arguments[0]).column->convert_to_full_column_if_const();
|
||||
const auto size = col->size();
|
||||
|
||||
std::unique_ptr<GeoShape> shape;
|
||||
|
||||
for (int row = 0; row < size; ++row) {
|
||||
auto shape_value = col->get_data_at(row);
|
||||
shape.reset(GeoShape::from_encoded(shape_value.data, shape_value.size));
|
||||
if (shape == nullptr) {
|
||||
res->insert_data(nullptr, 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
std::string binary = GeoShape::as_ewkb(shape.get());
|
||||
if (binary.empty()) {
|
||||
res->insert_data(nullptr, 0);
|
||||
continue;
|
||||
}
|
||||
res->insert_data(binary.data(), binary.size());
|
||||
}
|
||||
|
||||
block.replace_by_position(result, std::move(res));
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
static Status open(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
||||
static Status close(FunctionContext* context, FunctionContext::FunctionStateScope scope) {
|
||||
return Status::OK();
|
||||
}
|
||||
};
|
||||
|
||||
void register_function_geo(SimpleFunctionFactory& factory) {
|
||||
factory.register_function<GeoFunction<StPoint>>();
|
||||
factory.register_function<GeoFunction<StAsText<StAsWktName>>>();
|
||||
@ -588,6 +776,12 @@ void register_function_geo(SimpleFunctionFactory& factory) {
|
||||
factory.register_function<GeoFunction<StGeoFromText<StPolyFromText>>>();
|
||||
factory.register_function<GeoFunction<StAreaSquareMeters, DataTypeFloat64>>();
|
||||
factory.register_function<GeoFunction<StAreaSquareKm, DataTypeFloat64>>();
|
||||
factory.register_function<GeoFunction<StGeoFromWkb<StGeometryFromWKB>>>();
|
||||
factory.register_function<GeoFunction<StGeoFromWkb<StGeomFromWKB>>>();
|
||||
factory.register_function<GeoFunction<StGeoFromEwkb<StGeometryFromEWKB>>>();
|
||||
factory.register_function<GeoFunction<StGeoFromEwkb<StGeomFromEWKB>>>();
|
||||
factory.register_function<GeoFunction<StAsBinary>>();
|
||||
factory.register_function<GeoFunction<StAsEwkb>>();
|
||||
}
|
||||
|
||||
} // namespace doris::vectorized
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
---
|
||||
{
|
||||
"title": "ST_AsBinary",
|
||||
"language": "en"
|
||||
}
|
||||
---
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## ST_AsBinary
|
||||
|
||||
### Syntax
|
||||
|
||||
`VARCHAR ST_AsBinary(GEOMETRY geo)`
|
||||
|
||||
### Description
|
||||
|
||||
Converting a geometric figure into a standard WKB (Well-known binary) representation
|
||||
|
||||
Currently supported geometric figures are: Point, LineString, Polygon.
|
||||
|
||||
### example
|
||||
|
||||
```
|
||||
mysql> select ST_AsBinary(st_point(24.7, 56.7));
|
||||
+-----------------------------------+
|
||||
| st_asbinary(st_point(24.7, 56.7)) |
|
||||
+-----------------------------------+
|
||||
| 33333�8@�����YL@ |
|
||||
+-----------------------------------+
|
||||
1 row in set (0.04 sec)
|
||||
|
||||
mysql> select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)"));
|
||||
+-----------------------------------------------------------+
|
||||
| st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')) |
|
||||
+-----------------------------------------------------------+
|
||||
| �������? �? @�������? |
|
||||
+-----------------------------------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"));
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) |
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| �8
|
||||
毆\@.���6@B�! �\@0Ie�9�6@��-�\@��6�4�6@ޒ���\@·g 2�6@,�̆\@{1��6@�8
|
||||
毆\@.���6@ |
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.01 sec)
|
||||
|
||||
```
|
||||
### keywords
|
||||
ST_ASBINARY,ST,ASBINARY
|
||||
@ -0,0 +1,70 @@
|
||||
---
|
||||
{
|
||||
"title": "ST_AsEWKB",
|
||||
"language": "en"
|
||||
}
|
||||
---
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## ST_AsEWKB
|
||||
|
||||
### Syntax
|
||||
|
||||
`VARCHAR ST_AsEWKB(GEOMETRY geo)`
|
||||
|
||||
### Description
|
||||
|
||||
Converting a geometric figure into a EWKB (Extended Well-known binary) representation
|
||||
|
||||
Currently supported geometric figures are: Point, LineString, Polygon.
|
||||
|
||||
### example
|
||||
|
||||
```
|
||||
mysql> select ST_AsEWKB(st_point(24.7, 56.7));
|
||||
+---------------------------------+
|
||||
| st_asewkb(st_point(24.7, 56.7)) |
|
||||
+---------------------------------+
|
||||
| � 33333�8@�����YL@ |
|
||||
+---------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> select ST_AsEWKB(ST_GeometryFromText("LINESTRING (1 1, 2 2)"));
|
||||
+---------------------------------------------------------+
|
||||
| st_asewkb(st_geometryfromtext('LINESTRING (1 1, 2 2)')) |
|
||||
+---------------------------------------------------------+
|
||||
| � �������? �? @�������? |
|
||||
+---------------------------------------------------------+
|
||||
1 row in set (0.01 sec)
|
||||
|
||||
mysql> select ST_AsEWKB(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"));
|
||||
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_asewkb(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) |
|
||||
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| � �8
|
||||
毆\@.���6@B�! �\@0Ie�9�6@��-�\@��6�4�6@ޒ���\@·g 2�6@,�̆\@{1��6@�8
|
||||
毆\@.���6@ |
|
||||
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.01 sec)
|
||||
|
||||
```
|
||||
### keywords
|
||||
ST_ASWEKB,ST,ASEWKB
|
||||
@ -0,0 +1,93 @@
|
||||
---
|
||||
{
|
||||
"title": "ST_GeometryFromEWKB,ST_GeomFromEWKB",
|
||||
"language": "en"
|
||||
}
|
||||
---
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## ST_GeometryFromEWKB,ST_GeomFromEWKB
|
||||
|
||||
### Syntax
|
||||
|
||||
`GEOMETRY ST_GeometryFromEWKB(VARCHAR EWKB)`
|
||||
|
||||
### Description
|
||||
|
||||
Converting a EWKB (Extended Well-known binary) into a corresponding memory geometry
|
||||
|
||||
Since the GIS function of doris is implemented based on the WGS84 coordinate system, it can only parse EWKB data with SRID 4326, and return NULL for EWKB data with SRID other than 4326.
|
||||
|
||||
### example
|
||||
|
||||
```
|
||||
mysql> select ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_Point(24.7, 56.7))));
|
||||
+-----------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromewkb(st_asewkb(st_point(24.7, 56.7)))) |
|
||||
+-----------------------------------------------------------------+
|
||||
| POINT (24.7 56.7) |
|
||||
+-----------------------------------------------------------------+
|
||||
1 row in set (0.04 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
|
||||
+-----------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromewkb(st_asewkb(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
|
||||
+-----------------------------------------------------------------------------------------+
|
||||
| LINESTRING (1 1, 2 2) |
|
||||
+-----------------------------------------------------------------------------------------+
|
||||
1 row in set (0.11 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"))));
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromewkb(st_asewkb(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) |
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) |
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.03 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
|
||||
+-------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geomfromewkb(st_asewkb(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
|
||||
+-------------------------------------------------------------------------------------+
|
||||
| LINESTRING (1 1, 2 2) |
|
||||
+-------------------------------------------------------------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"))));
|
||||
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geomfromewkb(st_asewkb(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) |
|
||||
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) |
|
||||
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.03 sec)
|
||||
|
||||
//Parsing WKB data returns NULL.
|
||||
mysql> select ST_AsText(ST_GeometryFromEWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
|
||||
+-------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromewkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
|
||||
+-------------------------------------------------------------------------------------------+
|
||||
| NULL |
|
||||
+-------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
```
|
||||
### keywords
|
||||
ST_GEOMETRYFROMEWKB,ST_GEOMFROMEWKB,ST,GEOMETRYFROMEWKB,GEOMFROMEWKB,EWKB
|
||||
@ -0,0 +1,90 @@
|
||||
---
|
||||
{
|
||||
"title": "ST_GeometryFromWKB,ST_GeomFromWKB",
|
||||
"language": "en"
|
||||
}
|
||||
---
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## ST_GeometryFromWKB,ST_GeomFromWKB
|
||||
|
||||
### Syntax
|
||||
|
||||
`GEOMETRY ST_GeometryFromWKB(VARCHAR WKB)`
|
||||
|
||||
### Description
|
||||
|
||||
Converting a standard WKB (Well-known binary) into a corresponding memory geometry
|
||||
|
||||
### example
|
||||
|
||||
```
|
||||
mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7))));
|
||||
+------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) |
|
||||
+------------------------------------------------------------------+
|
||||
| POINT (24.7 56.7) |
|
||||
+------------------------------------------------------------------+
|
||||
1 row in set (0.05 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7))));
|
||||
+--------------------------------------------------------------+
|
||||
| st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) |
|
||||
+--------------------------------------------------------------+
|
||||
| POINT (24.7 56.7) |
|
||||
+--------------------------------------------------------------+
|
||||
1 row in set (0.03 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
|
||||
+------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
|
||||
+------------------------------------------------------------------------------------------+
|
||||
| LINESTRING (1 1, 2 2) |
|
||||
+------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.06 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
|
||||
+--------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geomfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
|
||||
+--------------------------------------------------------------------------------------+
|
||||
| LINESTRING (1 1, 2 2) |
|
||||
+--------------------------------------------------------------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"))));
|
||||
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) |
|
||||
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) |
|
||||
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.03 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"))));
|
||||
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) |
|
||||
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) |
|
||||
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.03 sec)
|
||||
|
||||
```
|
||||
### keywords
|
||||
ST_GEOMETRYFROMWKB,ST_GEOMFROMWKB,ST,GEOMETRYFROMWKB,GEOMFROMWKB,WKB
|
||||
@ -393,7 +393,11 @@
|
||||
"sql-manual/sql-functions/spatial-functions/st_astext",
|
||||
"sql-manual/sql-functions/spatial-functions/st_contains",
|
||||
"sql-manual/sql-functions/spatial-functions/st_geometryfromtext",
|
||||
"sql-manual/sql-functions/spatial-functions/st_linefromtext"
|
||||
"sql-manual/sql-functions/spatial-functions/st_linefromtext",
|
||||
"sql-manual/sql-functions/spatial-functions/st_asbinary",
|
||||
"sql-manual/sql-functions/spatial-functions/st_asewkb",
|
||||
"sql-manual/sql-functions/spatial-functions/st_geometryfromwkb",
|
||||
"sql-manual/sql-functions/spatial-functions/st_geometryfromewkb"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
---
|
||||
{
|
||||
"title": "ST_AsBinary",
|
||||
"language": "zh-CN"
|
||||
}
|
||||
---
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## ST_AsBinary
|
||||
|
||||
### Syntax
|
||||
|
||||
`VARCHAR ST_AsBinary(GEOMETRY geo)`
|
||||
|
||||
### Description
|
||||
|
||||
将一个几何图形转化为一个标准 WKB(Well-known binary)的表示形式。
|
||||
|
||||
目前支持对几何图形是:Point, LineString, Polygon。
|
||||
|
||||
### example
|
||||
|
||||
```
|
||||
mysql> select ST_AsBinary(st_point(24.7, 56.7));
|
||||
+-----------------------------------+
|
||||
| st_asbinary(st_point(24.7, 56.7)) |
|
||||
+-----------------------------------+
|
||||
| 33333�8@�����YL@ |
|
||||
+-----------------------------------+
|
||||
1 row in set (0.04 sec)
|
||||
|
||||
mysql> select ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)"));
|
||||
+-----------------------------------------------------------+
|
||||
| st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')) |
|
||||
+-----------------------------------------------------------+
|
||||
| �������? �? @�������? |
|
||||
+-----------------------------------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> select ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"));
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) |
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| �8
|
||||
毆\@.���6@B�! �\@0Ie�9�6@��-�\@��6�4�6@ޒ���\@·g 2�6@,�̆\@{1��6@�8
|
||||
毆\@.���6@ |
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.01 sec)
|
||||
|
||||
```
|
||||
### keywords
|
||||
ST_ASBINARY,ST,ASBINARY
|
||||
@ -0,0 +1,70 @@
|
||||
---
|
||||
{
|
||||
"title": "ST_AsEWKB",
|
||||
"language": "zh-CN"
|
||||
}
|
||||
---
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## ST_AsEWKB
|
||||
|
||||
### Syntax
|
||||
|
||||
`VARCHAR ST_AsEWKB(GEOMETRY geo)`
|
||||
|
||||
### Description
|
||||
|
||||
将一个几何图形转化为一个扩展 WKB(Extended Well-known binary)的表示形式。
|
||||
|
||||
目前支持对几何图形是:Point, LineString, Polygon。
|
||||
|
||||
### example
|
||||
|
||||
```
|
||||
mysql> select ST_AsEWKB(st_point(24.7, 56.7));
|
||||
+---------------------------------+
|
||||
| st_asewkb(st_point(24.7, 56.7)) |
|
||||
+---------------------------------+
|
||||
| � 33333�8@�����YL@ |
|
||||
+---------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> select ST_AsEWKB(ST_GeometryFromText("LINESTRING (1 1, 2 2)"));
|
||||
+---------------------------------------------------------+
|
||||
| st_asewkb(st_geometryfromtext('LINESTRING (1 1, 2 2)')) |
|
||||
+---------------------------------------------------------+
|
||||
| � �������? �? @�������? |
|
||||
+---------------------------------------------------------+
|
||||
1 row in set (0.01 sec)
|
||||
|
||||
mysql> select ST_AsEWKB(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"));
|
||||
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_asewkb(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')) |
|
||||
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| � �8
|
||||
毆\@.���6@B�! �\@0Ie�9�6@��-�\@��6�4�6@ޒ���\@·g 2�6@,�̆\@{1��6@�8
|
||||
毆\@.���6@ |
|
||||
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.01 sec)
|
||||
|
||||
```
|
||||
### keywords
|
||||
ST_ASWEKB,ST,ASEWKB
|
||||
@ -0,0 +1,92 @@
|
||||
---
|
||||
{
|
||||
"title": "ST_GeometryFromEWKB,ST_GeomFromEWKB",
|
||||
"language": "zh-CN"
|
||||
}
|
||||
---
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## ST_GeometryFromEWKB,ST_GeomFromEWKB
|
||||
|
||||
### Syntax
|
||||
|
||||
`GEOMETRY ST_GeometryFromEWKB(VARCHAR EWKB)`
|
||||
|
||||
### Description
|
||||
|
||||
将一个扩展 WKB(Extended Well-known binary)转化为对应的内存的几何形式。
|
||||
由于doris的地理函数基于 WGS84 坐标系实现的,因此只能解析SRID为4326的EWKB数据,对于SRID不为4326的EWKB数据返回 NULL。
|
||||
|
||||
### example
|
||||
|
||||
```
|
||||
mysql> select ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_Point(24.7, 56.7))));
|
||||
+-----------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromewkb(st_asewkb(st_point(24.7, 56.7)))) |
|
||||
+-----------------------------------------------------------------+
|
||||
| POINT (24.7 56.7) |
|
||||
+-----------------------------------------------------------------+
|
||||
1 row in set (0.04 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
|
||||
+-----------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromewkb(st_asewkb(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
|
||||
+-----------------------------------------------------------------------------------------+
|
||||
| LINESTRING (1 1, 2 2) |
|
||||
+-----------------------------------------------------------------------------------------+
|
||||
1 row in set (0.11 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"))));
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromewkb(st_asewkb(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) |
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) |
|
||||
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.03 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
|
||||
+-------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geomfromewkb(st_asewkb(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
|
||||
+-------------------------------------------------------------------------------------+
|
||||
| LINESTRING (1 1, 2 2) |
|
||||
+-------------------------------------------------------------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"))));
|
||||
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geomfromewkb(st_asewkb(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) |
|
||||
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) |
|
||||
+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.03 sec)
|
||||
|
||||
//解析WKB数据返回NULL
|
||||
mysql> select ST_AsText(ST_GeometryFromEWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
|
||||
+-------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromewkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
|
||||
+-------------------------------------------------------------------------------------------+
|
||||
| NULL |
|
||||
+-------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
```
|
||||
### keywords
|
||||
ST_GEOMETRYFROMEWKB,ST_GEOMFROMEWKB,ST,GEOMETRYFROMEWKB,GEOMFROMEWKB,EWKB
|
||||
@ -0,0 +1,99 @@
|
||||
---
|
||||
{
|
||||
"title": "ST_GeometryFromWKB,ST_GeomFromWKB",
|
||||
"language": "zh-CN"
|
||||
}
|
||||
---
|
||||
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
|
||||
## ST_GeometryFromWKB,ST_GeomFromWKB
|
||||
|
||||
### Syntax
|
||||
|
||||
`GEOMETRY ST_GeometryFromWKB(VARCHAR WKB)`
|
||||
|
||||
### Description
|
||||
|
||||
将一个标准 WKB(Well-known binary)转化为对应的内存的几何形式
|
||||
|
||||
### example
|
||||
|
||||
```
|
||||
mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7))));
|
||||
+------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromwkb(st_asbinary(st_point(24.7, 56.7)))) |
|
||||
+------------------------------------------------------------------+
|
||||
| POINT (24.7 56.7) |
|
||||
+------------------------------------------------------------------+
|
||||
1 row in set (0.05 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7))));
|
||||
+--------------------------------------------------------------+
|
||||
| st_astext(st_geomfromwkb(st_asbinary(st_point(24.7, 56.7)))) |
|
||||
+--------------------------------------------------------------+
|
||||
| POINT (24.7 56.7) |
|
||||
+--------------------------------------------------------------+
|
||||
1 row in set (0.03 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
|
||||
+------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
|
||||
+------------------------------------------------------------------------------------------+
|
||||
| LINESTRING (1 1, 2 2) |
|
||||
+------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.06 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_GeometryFromText("LINESTRING (1 1, 2 2)"))));
|
||||
+--------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geomfromwkb(st_asbinary(st_geometryfromtext('LINESTRING (1 1, 2 2)')))) |
|
||||
+--------------------------------------------------------------------------------------+
|
||||
| LINESTRING (1 1, 2 2) |
|
||||
+--------------------------------------------------------------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"))));
|
||||
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) |
|
||||
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) |
|
||||
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.03 sec)
|
||||
|
||||
mysql> select ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon("POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))"))));
|
||||
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| st_astext(st_geomfromwkb(st_asbinary(st_polygon('POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))')))) |
|
||||
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
| POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119)) |
|
||||
+-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
|
||||
1 row in set (0.03 sec)
|
||||
|
||||
//解析EWKB数据返回NULL
|
||||
mysql> select ST_AsText(ST_GeometryFromWKB(ST_AsEWKB(ST_Point(24.7, 56.7))));
|
||||
+----------------------------------------------------------------+
|
||||
| st_astext(st_geometryfromwkb(st_asewkb(st_point(24.7, 56.7)))) |
|
||||
+----------------------------------------------------------------+
|
||||
| NULL |
|
||||
+----------------------------------------------------------------+
|
||||
1 row in set (0.02 sec)
|
||||
|
||||
```
|
||||
### keywords
|
||||
ST_GEOMETRYFROMWKB,ST_GEOMFROMWKB,ST,GEOMETRYFROMWKB,GEOMFROMWKB,WKB
|
||||
@ -272,12 +272,18 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.StAngle;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAngleSphere;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAreaSquareKm;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAreaSquareMeters;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAsBinary;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAsEWKB;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAstext;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAswkt;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAzimuth;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StCircle;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StContains;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StDistanceSphere;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeomFromEWKB;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeomFromWKB;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeometryFromEWKB;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeometryFromWKB;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeometryfromtext;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeomfromtext;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StLinefromtext;
|
||||
@ -596,6 +602,8 @@ public class BuiltinScalarFunctions implements FunctionHelper {
|
||||
scalar(SplitByString.class, "split_by_string"),
|
||||
scalar(SplitPart.class, "split_part"),
|
||||
scalar(Sqrt.class, "sqrt"),
|
||||
scalar(StAsBinary.class, "st_asbinary"),
|
||||
scalar(StAsEWKB.class, "st_asewkb"),
|
||||
scalar(StAstext.class, "st_astext"),
|
||||
scalar(StAswkt.class, "st_aswkt"),
|
||||
scalar(StCircle.class, "st_circle"),
|
||||
@ -606,8 +614,12 @@ public class BuiltinScalarFunctions implements FunctionHelper {
|
||||
scalar(StAzimuth.class, "st_azimuth"),
|
||||
scalar(StAreaSquareMeters.class, "st_area_square_meters"),
|
||||
scalar(StAreaSquareKm.class, "st_area_square_km"),
|
||||
scalar(StGeometryFromEWKB.class, "st_geometryfromewkb"),
|
||||
scalar(StGeometryfromtext.class, "st_geometryfromtext"),
|
||||
scalar(StGeometryFromWKB.class, "st_geometryfromwkb"),
|
||||
scalar(StGeomFromEWKB.class, "st_geomfromewkb"),
|
||||
scalar(StGeomfromtext.class, "st_geomfromtext"),
|
||||
scalar(StGeomFromWKB.class, "st_geomfromwkb"),
|
||||
scalar(StLinefromtext.class, "st_linefromtext"),
|
||||
scalar(StLinestringfromtext.class, "st_linestringfromtext"),
|
||||
scalar(StPoint.class, "st_point"),
|
||||
|
||||
@ -0,0 +1,70 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.StringType;
|
||||
import org.apache.doris.nereids.types.VarcharType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'st_asbinary'. This class is generated by GenerateFunction.
|
||||
*/
|
||||
public class StAsBinary extends ScalarFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE)
|
||||
);
|
||||
|
||||
/**
|
||||
* constructor with 1 argument.
|
||||
*/
|
||||
public StAsBinary(Expression arg) {
|
||||
super("st_asbinary", arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* withChildren.
|
||||
*/
|
||||
@Override
|
||||
public StAsBinary withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 1);
|
||||
return new StAsBinary(children.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitStAsBinary(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.StringType;
|
||||
import org.apache.doris.nereids.types.VarcharType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'st_asewkb'. This class is generated by GenerateFunction.
|
||||
*/
|
||||
public class StAsEWKB extends ScalarFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE)
|
||||
);
|
||||
|
||||
/**
|
||||
* constructor with 1 argument.
|
||||
*/
|
||||
public StAsEWKB(Expression arg) {
|
||||
super("st_asewkb", arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* withChildren.
|
||||
*/
|
||||
@Override
|
||||
public StAsEWKB withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 1);
|
||||
return new StAsEWKB(children.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitStAsEWKB(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.StringType;
|
||||
import org.apache.doris.nereids.types.VarcharType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'st_geomfromewkb'. This class is generated by GenerateFunction.
|
||||
*/
|
||||
public class StGeomFromEWKB extends ScalarFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE)
|
||||
);
|
||||
|
||||
/**
|
||||
* constructor with 1 argument.
|
||||
*/
|
||||
public StGeomFromEWKB(Expression arg) {
|
||||
super("st_geomfromewkb", arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* withChildren.
|
||||
*/
|
||||
@Override
|
||||
public StGeomFromEWKB withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 1);
|
||||
return new StGeomFromEWKB(children.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitStGeomfromewkb(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.StringType;
|
||||
import org.apache.doris.nereids.types.VarcharType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'st_geomfromwkb'. This class is generated by GenerateFunction.
|
||||
*/
|
||||
public class StGeomFromWKB extends ScalarFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE)
|
||||
);
|
||||
|
||||
/**
|
||||
* constructor with 1 argument.
|
||||
*/
|
||||
public StGeomFromWKB(Expression arg) {
|
||||
super("st_geomfromwkb", arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* withChildren.
|
||||
*/
|
||||
@Override
|
||||
public StGeomFromWKB withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 1);
|
||||
return new StGeomFromWKB(children.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitStGeomfromwkb(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.StringType;
|
||||
import org.apache.doris.nereids.types.VarcharType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'st_geometryfromewkb'. This class is generated by GenerateFunction.
|
||||
*/
|
||||
public class StGeometryFromEWKB extends ScalarFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE)
|
||||
);
|
||||
|
||||
/**
|
||||
* constructor with 1 argument.
|
||||
*/
|
||||
public StGeometryFromEWKB(Expression arg) {
|
||||
super("st_geometryfromewkb", arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* withChildren.
|
||||
*/
|
||||
@Override
|
||||
public StGeometryFromEWKB withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 1);
|
||||
return new StGeometryFromEWKB(children.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitStGeometryfromewkb(this, context);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,70 @@
|
||||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.doris.nereids.trees.expressions.functions.scalar;
|
||||
|
||||
import org.apache.doris.catalog.FunctionSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.Expression;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
|
||||
import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
|
||||
import org.apache.doris.nereids.trees.expressions.visitor.ExpressionVisitor;
|
||||
import org.apache.doris.nereids.types.StringType;
|
||||
import org.apache.doris.nereids.types.VarcharType;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ScalarFunction 'st_geometryfromwkb'. This class is generated by GenerateFunction.
|
||||
*/
|
||||
public class StGeometryFromWKB extends ScalarFunction
|
||||
implements UnaryExpression, ExplicitlyCastableSignature, AlwaysNullable {
|
||||
|
||||
public static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(VarcharType.SYSTEM_DEFAULT),
|
||||
FunctionSignature.ret(VarcharType.SYSTEM_DEFAULT).args(StringType.INSTANCE)
|
||||
);
|
||||
|
||||
/**
|
||||
* constructor with 1 argument.
|
||||
*/
|
||||
public StGeometryFromWKB(Expression arg) {
|
||||
super("st_geometryfromwkb", arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* withChildren.
|
||||
*/
|
||||
@Override
|
||||
public StGeometryFromWKB withChildren(List<Expression> children) {
|
||||
Preconditions.checkArgument(children.size() == 1);
|
||||
return new StGeometryFromWKB(children.get(0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FunctionSignature> getSignatures() {
|
||||
return SIGNATURES;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <R, C> R accept(ExpressionVisitor<R, C> visitor, C context) {
|
||||
return visitor.visitStGeometryfromwkb(this, context);
|
||||
}
|
||||
}
|
||||
@ -274,12 +274,18 @@ import org.apache.doris.nereids.trees.expressions.functions.scalar.StAngle;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAngleSphere;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAreaSquareKm;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAreaSquareMeters;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAsBinary;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAsEWKB;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAstext;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAswkt;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StAzimuth;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StCircle;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StContains;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StDistanceSphere;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeomFromEWKB;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeomFromWKB;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeometryFromEWKB;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeometryFromWKB;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeometryfromtext;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StGeomfromtext;
|
||||
import org.apache.doris.nereids.trees.expressions.functions.scalar.StLinefromtext;
|
||||
@ -1436,6 +1442,30 @@ public interface ScalarFunctionVisitor<R, C> {
|
||||
return visitScalarFunction(stY, context);
|
||||
}
|
||||
|
||||
default R visitStGeometryfromwkb(StGeometryFromWKB stGeometryfromwkb, C context) {
|
||||
return visitScalarFunction(stGeometryfromwkb, context);
|
||||
}
|
||||
|
||||
default R visitStGeometryfromewkb(StGeometryFromEWKB stGeometryfromewkb, C context) {
|
||||
return visitScalarFunction(stGeometryfromewkb, context);
|
||||
}
|
||||
|
||||
default R visitStGeomfromwkb(StGeomFromWKB stGeomfromwkb, C context) {
|
||||
return visitScalarFunction(stGeomfromwkb, context);
|
||||
}
|
||||
|
||||
default R visitStGeomfromewkb(StGeomFromEWKB stGeomfromewkb, C context) {
|
||||
return visitScalarFunction(stGeomfromewkb, context);
|
||||
}
|
||||
|
||||
default R visitStAsBinary(StAsBinary stAsBinary, C context) {
|
||||
return visitScalarFunction(stAsBinary, context);
|
||||
}
|
||||
|
||||
default R visitStAsEWKB(StAsEWKB stAsEWKB, C context) {
|
||||
return visitScalarFunction(stAsEWKB, context);
|
||||
}
|
||||
|
||||
default R visitStartsWith(StartsWith startsWith, C context) {
|
||||
return visitScalarFunction(startsWith, context);
|
||||
}
|
||||
|
||||
@ -1771,6 +1771,18 @@ visible_functions = [
|
||||
[['ST_GeometryFromText', 'ST_GeomFromText'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NULLABLE'],
|
||||
[['ST_GeometryFromText', 'ST_GeomFromText'], 'VARCHAR', ['STRING'], 'ALWAYS_NULLABLE'],
|
||||
|
||||
[['ST_GeometryFromWkb', 'ST_GeomFromWkb'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NULLABLE'],
|
||||
[['ST_GeometryFromWkb', 'ST_GeomFromWkb'], 'VARCHAR', ['STRING'], 'ALWAYS_NULLABLE'],
|
||||
|
||||
[['ST_GeometryFromEwkb', 'ST_GeomFromEwkb'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NULLABLE'],
|
||||
[['ST_GeometryFromEwkb', 'ST_GeomFromEwkb'], 'VARCHAR', ['STRING'], 'ALWAYS_NULLABLE'],
|
||||
|
||||
[['ST_AsBinary'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NULLABLE'],
|
||||
[['ST_AsBinary'], 'VARCHAR', ['STRING'], 'ALWAYS_NULLABLE'],
|
||||
|
||||
[['ST_AsEwkb'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NULLABLE'],
|
||||
[['ST_AsEwkb'], 'VARCHAR', ['STRING'], 'ALWAYS_NULLABLE'],
|
||||
|
||||
[['ST_LineFromText', 'ST_LineStringFromText'], 'VARCHAR', ['VARCHAR'], 'ALWAYS_NULLABLE'],
|
||||
[['ST_LineFromText', 'ST_LineStringFromText'], 'VARCHAR', ['STRING'], 'ALWAYS_NULLABLE'],
|
||||
|
||||
|
||||
@ -2176,6 +2176,180 @@ POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4))
|
||||
59.939093
|
||||
79.939093
|
||||
|
||||
-- !sql_st_asbinary_Varchar --
|
||||
\N
|
||||
POINT (-46.35620117 39.939093)
|
||||
POINT (-74.35620117 79.939093)
|
||||
POINT (126.35620117 -39.939093)
|
||||
POINT (16.35620117 19.939093)
|
||||
POINT (43.35620117 35.939093)
|
||||
POINT (47.35620117 26.939093)
|
||||
POINT (5 5)
|
||||
POINT (90.35620117 39.939093)
|
||||
POINT (90.35620117 47.939093)
|
||||
POINT (90.35620117 49.939093)
|
||||
POINT (90.35620117 59.939093)
|
||||
POINT (98.35620117 36.939093)
|
||||
|
||||
-- !sql_st_asbinary_Varchar_notnull --
|
||||
POINT (-46.35620117 39.939093)
|
||||
POINT (-74.35620117 79.939093)
|
||||
POINT (126.35620117 -39.939093)
|
||||
POINT (16.35620117 19.939093)
|
||||
POINT (43.35620117 35.939093)
|
||||
POINT (47.35620117 26.939093)
|
||||
POINT (5 5)
|
||||
POINT (90.35620117 39.939093)
|
||||
POINT (90.35620117 47.939093)
|
||||
POINT (90.35620117 49.939093)
|
||||
POINT (90.35620117 59.939093)
|
||||
POINT (98.35620117 36.939093)
|
||||
|
||||
-- !sql_st_geometryfromwkb_Varchar --
|
||||
\N
|
||||
POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))
|
||||
POLYGON ((0 0, 12 0, 10 16, 1 10, 0 0))
|
||||
POLYGON ((0 0, 38 4, 38 37, 4 1, 0 0))
|
||||
POLYGON ((1 1, 11 4, 42 44, 4 18, 1 1))
|
||||
POLYGON ((1 1, 16 1, 16 16, 1 16, 1 1))
|
||||
POLYGON ((1 1, 34 1, 34 34, 1 34, 1 1))
|
||||
POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1))
|
||||
POLYGON ((1 1, 5 0, 10 4, 4 3, 1 1))
|
||||
POLYGON ((1 1, 56 0, 67 89, 4 32, 1 1))
|
||||
POLYGON ((1 1, 8 0, 48 34, 4 10, 1 1))
|
||||
POLYGON ((4 1, 10 4, 9 4, 1 1, 4 1))
|
||||
POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4))
|
||||
|
||||
-- !sql_st_geometryfromwkb_Varchar_notnull --
|
||||
POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))
|
||||
POLYGON ((0 0, 12 0, 10 16, 1 10, 0 0))
|
||||
POLYGON ((0 0, 38 4, 38 37, 4 1, 0 0))
|
||||
POLYGON ((1 1, 11 4, 42 44, 4 18, 1 1))
|
||||
POLYGON ((1 1, 16 1, 16 16, 1 16, 1 1))
|
||||
POLYGON ((1 1, 34 1, 34 34, 1 34, 1 1))
|
||||
POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1))
|
||||
POLYGON ((1 1, 5 0, 10 4, 4 3, 1 1))
|
||||
POLYGON ((1 1, 56 0, 67 89, 4 32, 1 1))
|
||||
POLYGON ((1 1, 8 0, 48 34, 4 10, 1 1))
|
||||
POLYGON ((4 1, 10 4, 9 4, 1 1, 4 1))
|
||||
POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4))
|
||||
|
||||
-- !sql_st_geomfromwkb_Varchar --
|
||||
\N
|
||||
POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))
|
||||
POLYGON ((0 0, 12 0, 10 16, 1 10, 0 0))
|
||||
POLYGON ((0 0, 38 4, 38 37, 4 1, 0 0))
|
||||
POLYGON ((1 1, 11 4, 42 44, 4 18, 1 1))
|
||||
POLYGON ((1 1, 16 1, 16 16, 1 16, 1 1))
|
||||
POLYGON ((1 1, 34 1, 34 34, 1 34, 1 1))
|
||||
POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1))
|
||||
POLYGON ((1 1, 5 0, 10 4, 4 3, 1 1))
|
||||
POLYGON ((1 1, 56 0, 67 89, 4 32, 1 1))
|
||||
POLYGON ((1 1, 8 0, 48 34, 4 10, 1 1))
|
||||
POLYGON ((4 1, 10 4, 9 4, 1 1, 4 1))
|
||||
POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4))
|
||||
|
||||
-- !sql_st_geomfromwkb_Varchar_notnull --
|
||||
POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))
|
||||
POLYGON ((0 0, 12 0, 10 16, 1 10, 0 0))
|
||||
POLYGON ((0 0, 38 4, 38 37, 4 1, 0 0))
|
||||
POLYGON ((1 1, 11 4, 42 44, 4 18, 1 1))
|
||||
POLYGON ((1 1, 16 1, 16 16, 1 16, 1 1))
|
||||
POLYGON ((1 1, 34 1, 34 34, 1 34, 1 1))
|
||||
POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1))
|
||||
POLYGON ((1 1, 5 0, 10 4, 4 3, 1 1))
|
||||
POLYGON ((1 1, 56 0, 67 89, 4 32, 1 1))
|
||||
POLYGON ((1 1, 8 0, 48 34, 4 10, 1 1))
|
||||
POLYGON ((4 1, 10 4, 9 4, 1 1, 4 1))
|
||||
POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4))
|
||||
|
||||
-- !sql_st_asewkb_Varchar --
|
||||
\N
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
|
||||
-- !sql_st_asewkb_Varchar_notnull --
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
LINESTRING (1 1, 2 2)
|
||||
|
||||
-- !sql_st_geometryfromewkb_Varchar --
|
||||
\N
|
||||
POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))
|
||||
POLYGON ((0 0, 12 0, 10 16, 1 10, 0 0))
|
||||
POLYGON ((0 0, 38 4, 38 37, 4 1, 0 0))
|
||||
POLYGON ((1 1, 11 4, 42 44, 4 18, 1 1))
|
||||
POLYGON ((1 1, 16 1, 16 16, 1 16, 1 1))
|
||||
POLYGON ((1 1, 34 1, 34 34, 1 34, 1 1))
|
||||
POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1))
|
||||
POLYGON ((1 1, 5 0, 10 4, 4 3, 1 1))
|
||||
POLYGON ((1 1, 56 0, 67 89, 4 32, 1 1))
|
||||
POLYGON ((1 1, 8 0, 48 34, 4 10, 1 1))
|
||||
POLYGON ((4 1, 10 4, 9 4, 1 1, 4 1))
|
||||
POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4))
|
||||
|
||||
-- !sql_st_geometryfromewkb_Varchar_notnull --
|
||||
POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))
|
||||
POLYGON ((0 0, 12 0, 10 16, 1 10, 0 0))
|
||||
POLYGON ((0 0, 38 4, 38 37, 4 1, 0 0))
|
||||
POLYGON ((1 1, 11 4, 42 44, 4 18, 1 1))
|
||||
POLYGON ((1 1, 16 1, 16 16, 1 16, 1 1))
|
||||
POLYGON ((1 1, 34 1, 34 34, 1 34, 1 1))
|
||||
POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1))
|
||||
POLYGON ((1 1, 5 0, 10 4, 4 3, 1 1))
|
||||
POLYGON ((1 1, 56 0, 67 89, 4 32, 1 1))
|
||||
POLYGON ((1 1, 8 0, 48 34, 4 10, 1 1))
|
||||
POLYGON ((4 1, 10 4, 9 4, 1 1, 4 1))
|
||||
POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4))
|
||||
|
||||
-- !sql_st_geomfromewkb_Varchar --
|
||||
\N
|
||||
POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))
|
||||
POLYGON ((0 0, 12 0, 10 16, 1 10, 0 0))
|
||||
POLYGON ((0 0, 38 4, 38 37, 4 1, 0 0))
|
||||
POLYGON ((1 1, 11 4, 42 44, 4 18, 1 1))
|
||||
POLYGON ((1 1, 16 1, 16 16, 1 16, 1 1))
|
||||
POLYGON ((1 1, 34 1, 34 34, 1 34, 1 1))
|
||||
POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1))
|
||||
POLYGON ((1 1, 5 0, 10 4, 4 3, 1 1))
|
||||
POLYGON ((1 1, 56 0, 67 89, 4 32, 1 1))
|
||||
POLYGON ((1 1, 8 0, 48 34, 4 10, 1 1))
|
||||
POLYGON ((4 1, 10 4, 9 4, 1 1, 4 1))
|
||||
POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4))
|
||||
|
||||
-- !sql_st_geomfromewkb_Varchar_notnull --
|
||||
POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))
|
||||
POLYGON ((0 0, 12 0, 10 16, 1 10, 0 0))
|
||||
POLYGON ((0 0, 38 4, 38 37, 4 1, 0 0))
|
||||
POLYGON ((1 1, 11 4, 42 44, 4 18, 1 1))
|
||||
POLYGON ((1 1, 16 1, 16 16, 1 16, 1 1))
|
||||
POLYGON ((1 1, 34 1, 34 34, 1 34, 1 1))
|
||||
POLYGON ((1 1, 4 1, 4 4, 1 4, 1 1))
|
||||
POLYGON ((1 1, 5 0, 10 4, 4 3, 1 1))
|
||||
POLYGON ((1 1, 56 0, 67 89, 4 32, 1 1))
|
||||
POLYGON ((1 1, 8 0, 48 34, 4 10, 1 1))
|
||||
POLYGON ((4 1, 10 4, 9 4, 1 1, 4 1))
|
||||
POLYGON ((4 4, 45 4, 45 45, 4 45, 4 4))
|
||||
|
||||
-- !sql_starts_with_Varchar_Varchar --
|
||||
true
|
||||
true
|
||||
|
||||
@ -89,3 +89,39 @@ POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))
|
||||
-- !sql --
|
||||
\N
|
||||
|
||||
-- !sql --
|
||||
POINT (24.7 56.7)
|
||||
|
||||
-- !sql --
|
||||
LINESTRING (1 1, 2 2)
|
||||
|
||||
-- !sql --
|
||||
POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119))
|
||||
|
||||
-- !sql --
|
||||
POINT (24.7 56.7)
|
||||
|
||||
-- !sql --
|
||||
LINESTRING (1 1, 2 2)
|
||||
|
||||
-- !sql --
|
||||
POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119))
|
||||
|
||||
-- !sql --
|
||||
POINT (24.7 56.7)
|
||||
|
||||
-- !sql --
|
||||
LINESTRING (1 1, 2 2)
|
||||
|
||||
-- !sql --
|
||||
POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119))
|
||||
|
||||
-- !sql --
|
||||
POINT (24.7 56.7)
|
||||
|
||||
-- !sql --
|
||||
LINESTRING (1 1, 2 2)
|
||||
|
||||
-- !sql --
|
||||
POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119))
|
||||
|
||||
|
||||
@ -89,3 +89,39 @@ POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0))
|
||||
-- !sql --
|
||||
\N
|
||||
|
||||
-- !sql --
|
||||
POINT (24.7 56.7)
|
||||
|
||||
-- !sql --
|
||||
LINESTRING (1 1, 2 2)
|
||||
|
||||
-- !sql --
|
||||
POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119))
|
||||
|
||||
-- !sql --
|
||||
POINT (24.7 56.7)
|
||||
|
||||
-- !sql --
|
||||
LINESTRING (1 1, 2 2)
|
||||
|
||||
-- !sql --
|
||||
POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119))
|
||||
|
||||
-- !sql --
|
||||
POINT (24.7 56.7)
|
||||
|
||||
-- !sql --
|
||||
LINESTRING (1 1, 2 2)
|
||||
|
||||
-- !sql --
|
||||
POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119))
|
||||
|
||||
-- !sql --
|
||||
POINT (24.7 56.7)
|
||||
|
||||
-- !sql --
|
||||
LINESTRING (1 1, 2 2)
|
||||
|
||||
-- !sql --
|
||||
POLYGON ((114.104486 22.547119, 114.093758 22.547753, 114.096504 22.532057, 114.104229 22.539826, 114.106203 22.54268, 114.104486 22.547119))
|
||||
|
||||
|
||||
@ -244,6 +244,18 @@ suite("nereids_scalar_fn_S") {
|
||||
qt_sql_st_y_Varchar_notnull "select st_y(st_point(x_lng, x_lat)) from fn_test_not_nullable order by 1"
|
||||
qt_sql_st_y_String "select st_y(st_point(x_lng, x_lat)) from fn_test order by 1"
|
||||
qt_sql_st_y_String_notnull "select st_y(st_point(x_lng, x_lat)) from fn_test_not_nullable order by 1"
|
||||
qt_sql_st_asbinary_Varchar "select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(st_point(x_lng, x_lat)))) from fn_test order by 1"
|
||||
qt_sql_st_asbinary_Varchar_notnull "select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(st_point(x_lng, x_lat)))) from fn_test_not_nullable order by 1"
|
||||
qt_sql_st_geometryfromwkb_Varchar "select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(st_polyfromtext(polygon_wkt)))) from fn_test order by 1"
|
||||
qt_sql_st_geometryfromwkb_Varchar_notnull "select ST_AsText(ST_GeometryFromWKB(ST_AsBinary(st_polyfromtext(polygon_wkt)))) from fn_test_not_nullable order by 1"
|
||||
qt_sql_st_geomfromwkb_Varchar "select ST_AsText(ST_GeomFromWKB(ST_AsBinary(st_polyfromtext(polygon_wkt)))) from fn_test order by 1"
|
||||
qt_sql_st_geomfromwkb_Varchar_notnull "select ST_AsText(ST_GeomFromWKB(ST_AsBinary(st_polyfromtext(polygon_wkt)))) from fn_test_not_nullable order by 1"
|
||||
qt_sql_st_asewkb_Varchar "select ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(st_linestringfromtext(linestring_wkt)))) from fn_test order by 1"
|
||||
qt_sql_st_asewkb_Varchar_notnull "select ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(st_linestringfromtext(linestring_wkt)))) from fn_test_not_nullable order by 1"
|
||||
qt_sql_st_geometryfromewkb_Varchar "select ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(st_polyfromtext(polygon_wkt)))) from fn_test order by 1"
|
||||
qt_sql_st_geometryfromewkb_Varchar_notnull "select ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(st_polyfromtext(polygon_wkt)))) from fn_test_not_nullable order by 1"
|
||||
qt_sql_st_geomfromewkb_Varchar "select ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(st_polyfromtext(polygon_wkt)))) from fn_test order by 1"
|
||||
qt_sql_st_geomfromewkb_Varchar_notnull "select ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(st_polyfromtext(polygon_wkt)))) from fn_test_not_nullable order by 1"
|
||||
|
||||
qt_sql_starts_with_Varchar_Varchar "select starts_with(kvchrs1, kvchrs1) from fn_test order by kvchrs1, kvchrs1"
|
||||
qt_sql_starts_with_Varchar_Varchar_notnull "select starts_with(kvchrs1, kvchrs1) from fn_test_not_nullable order by kvchrs1, kvchrs1"
|
||||
|
||||
@ -60,4 +60,21 @@ suite("test_gis_function") {
|
||||
qt_sql "SELECT St_Azimuth(ST_Point(0, 0),ST_Point(1, 0));"
|
||||
qt_sql "SELECT St_Azimuth(ST_Point(0, 0),ST_Point(0, 1));"
|
||||
qt_sql "SELECT St_Azimuth(ST_Point(-30, 0),ST_Point(150, 0));"
|
||||
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText(\"LINESTRING (1 1, 2 2)\"))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon(\"POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))\"))));"
|
||||
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_GeometryFromText(\"LINESTRING (1 1, 2 2)\"))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon(\"POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))\"))));"
|
||||
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_Point(24.7, 56.7))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_GeometryFromText(\"LINESTRING (1 1, 2 2)\"))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_Polygon(\"POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))\"))));"
|
||||
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(ST_Point(24.7, 56.7))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(ST_GeometryFromText(\"LINESTRING (1 1, 2 2)\"))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(ST_Polygon(\"POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))\"))));"
|
||||
|
||||
}
|
||||
|
||||
@ -59,4 +59,20 @@ suite("test_gis_function") {
|
||||
qt_sql "SELECT St_Azimuth(ST_Point(0, 0),ST_Point(1, 0));"
|
||||
qt_sql "SELECT St_Azimuth(ST_Point(0, 0),ST_Point(0, 1));"
|
||||
qt_sql "SELECT St_Azimuth(ST_Point(-30, 0),ST_Point(150, 0));"
|
||||
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Point(24.7, 56.7))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_GeometryFromText(\"LINESTRING (1 1, 2 2)\"))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromWKB(ST_AsBinary(ST_Polygon(\"POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))\"))));"
|
||||
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Point(24.7, 56.7))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_GeometryFromText(\"LINESTRING (1 1, 2 2)\"))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromWKB(ST_AsBinary(ST_Polygon(\"POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))\"))));"
|
||||
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_Point(24.7, 56.7))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_GeometryFromText(\"LINESTRING (1 1, 2 2)\"))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeometryFromEWKB(ST_AsEWKB(ST_Polygon(\"POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))\"))));"
|
||||
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(ST_Point(24.7, 56.7))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(ST_GeometryFromText(\"LINESTRING (1 1, 2 2)\"))));"
|
||||
qt_sql "SELECT ST_AsText(ST_GeomFromEWKB(ST_AsEWKB(ST_Polygon(\"POLYGON ((114.104486 22.547119,114.093758 22.547753,114.096504 22.532057,114.104229 22.539826,114.106203 22.542680,114.104486 22.547119))\"))));"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user