GeoPB规范如下:
syntax = "proto3";
package geopb;
// 几何对象类型枚举
enum GeometryType {
point = 0;
line_string = 1;
polygon = 2;
multi_point = 3;
multi_line_string = 4;
multi_polygon = 5;
geometry_collection = 6;
}
// 属性值类型枚举
enum PropertyValueType {
string_value = 0;
number_value = 1;
boolean_value = 2;
date_value = 3;
time_value = 4;
object_value = 5;
array_value = 6;
// 可以根据需要添加其他类型
}
// 坐标点
message Coordinate {
double latitude = 1; // 纬度
double longitude = 2; // 经度
double elevation = 3; // 海拔(可选)
}
// 几何对象
message Geometry {
GeometryType type = 1;// 几何类型
oneof geometry_type {
Point point = 2;
LineString line_string = 3;
Polygon polygon = 4;
MultiPoint multi_point = 5;
MultiLineString multi_line_string = 6;
MultiPolygon multi_polygon = 7;
GeometryCollection geometry_collection = 8;
}
}
// 点
message Point {
repeated Coordinate coordinates = 1; // 坐标数组,通常只包含一个点
}
// 线
message LineString {
repeated Coordinate coordinates = 1; // 坐标数组,表示线的顶点
}
// 多边形
message Polygon {
repeated LineString coordinates = 1; // 线字符串数组,表示多边形的边界
}
// 多点
message MultiPoint {
repeated Point coordinates = 1; // 点数组
}
// 多线
message MultiLineString {
repeated LineString coordinates = 1; // 线字符串数组
}
// 多多边形
message MultiPolygon {
repeated Polygon coordinates = 1; // 多边形数组
}
// 几何集合
message GeometryCollection {
repeated Geometry geometries = 1; // 几何对象数组
}
// 日期类型,使用字符串表示ISO 8601日期
message Date {
string value = 1; // ISO 8601格式的日期字符串,例如"2023-04-01"
}
// 时间类型,使用字符串表示ISO 8601时间
message Time {
string value = 1; // ISO 8601格式的时间字符串,例如"12:34:56Z"或"12:34:56+02:00"
}
// 对象类型,使用键值对表示
message JsonObject {
repeated Property properties = 1; // 属性键值对数组
}
// 数组类型,使用任意类型的元素
message JsonArray {
repeated PropertyValue elements = 1; // 属性值数组,元素可以是任何支持的类型
}
// 属性值,支持多种数据类型
message PropertyValue {
PropertyValueType type=1;
oneof value_type {
string string_value = 2; // 字符串值
double number_value = 3; // 数值(包括整数和浮点数)
bool boolean_value = 4; // 布尔值
Date date_value = 5; // 日期值
Time time_value = 6; // 时间值
JsonObject object_value = 7; // 对象值
JsonArray array_value = 8; // 数组值
// 可以根据需要添加其他类型
}
}
// 属性键值对
message Property {
string key = 1; // 属性的键
PropertyValue value = 2; // 属性的值
}
// GeoJSON特性
message Feature {
string id = 1; // 特性的ID
Geometry geometry = 2; // 几何对象
repeated Property properties = 3; // 属性键值对数组
}
// GeoJSON特性集合
message FeatureCollection {
repeated Feature features = 1; // 特性数组
}
// 根消息,封装GeoJSON数据
message GeoJsonData {
oneof data_type {
Feature feature = 1; // 单个特性
FeatureCollection feature_collection = 2; // 特性集合
}
}
欢迎大家对GeoPB规范提出优化意见,大家一起为GeoPB的发展贡献力量