gis原型模块

protobuf-gis的Python项目详细描述


安装

pip install protobuf-gis

附加功能

所有消息都有函数toGeoJSON,该函数返回消息的geojson表示。

消息

syntax = "proto3";

import "gis/protobuf/point.proto";

package test;

message Test {
  gis.protobuf.Point2D point2d = 1;
  gis.protobuf.Point3D point3d = 2;
  gis.protobuf.MultiPoint2D multi_point2d = 3;
  gis.protobuf.MultiPoint3D multi_point3d = 4;
}

点2d

具有两个类型为floatxy的字段的结构。

此消息的geojson表示为

{'type':'Point','coordinates':[x,y]}

点3d

具有类型为floatxyz的三个字段的结构。

此消息的geojson表示为

{'type':'Point','coordinates':[x,y,z]}

多点2d

一个重复字段类型为gis.protobuf.Point2Dpoint的结构。

此消息的geojson表示为

{'type':'MultiPoint','coordinates':[[x1,y1],[x2,y2]]}

多点3d

一个重复字段类型为gis.protobuf.Point3Dpoint的结构。

此消息的geojson表示为

{'type':'MultiPoint','coordinates':[[x1,y1,z1],[x2,y2,z2]]}

字符串

syntax = "proto3";

import "gis/protobuf/linestring.proto";

package test;

message Test {
  gis.protobuf.LineString2D line_string2d = 1;
  gis.protobuf.LineString3D line_string3d = 2;
  gis.protobuf.MultiLineString2D multi_line_string2d = 3;
  gis.protobuf.MultiLineString3D multi_line_string3d = 4;
}

行字符串2d

一个重复字段类型为gis.protobuf.Point2Dpoint的结构。

此消息的geojson表示为

{'type':'LineString','coordinates':[[x1,y1],[x2,y2]]}

linestring3d

一个重复字段类型为gis.protobuf.Point3Dpoint的结构。

此消息的geojson表示为

{'type':'LineString','coordinates':[[x1,y1,z1],[x2,y2,z2]]}

多行2d

一个重复字段类型为gis.protobuf.LineString2Dline_string的结构。

此消息的geojson表示为

{'type':'MultiLineString','coordinates':[[[x1,y1],[x2,y2]],[[x3,y3],[x4,y4]]]}

多行3d

一个重复字段类型为gis.protobuf.LineString3Dline_string的结构。

此消息的geojson表示为

{'type':'MultiLineString','coordinates':[[[x1,y1,z1],[x2,y2,z2]],[[x3,y3,z3],[x4,y4,z4]]]}

多边形

syntax = "proto3";

import "gis/protobuf/point.proto";

package test;

message Test {
  gis.protobuf.Polygon2D polugon2d = 1;
  gis.protobuf.Polygon3D polugon3d = 2;
  gis.protobuf.MultiPolygon2D multi_polugon2d = 3;
  gis.protobuf.MultiPolygon3D multi_polugon3d = 4;
}

多边形2d

一个重复字段类型为gis.protobuf.Point2Dpoint的结构。

此消息的geojson表示为

{'type':'Polygon','coordinates':[[[x1,y1],[x2,y2]]]}

Polygon3D

一个重复字段类型为gis.protobuf.Point3Dpoint的结构。

此消息的geojson表示为

{'type':'Polygon','coordinates':[[[x1,y1,z1],[x2,y2,z2]]]}

多多边形2d

一个重复字段类型为gis.protobuf.Polygon2Dpolygon的结构。

此消息的geojson表示为

{'type':'MultiPolygon','coordinates':[[[[x1,y1],[x2,y2]]],[[[x3,y3],[x4,y4]]]]}

多多边形3d

一个重复字段类型为gis.protobuf.Polygon3Dpolygon的结构。

此消息的geojson表示为

{'type':'MultiPolygon','coordinates':[[[[x1,y1,z1],[x2,y2,z2]]],[[[x3,y3,z3],[x4,y4,z4]]]]}

用法

proto/test.proto文件中:

syntax = "proto3";

import "gis/protobuf/point.proto";

package test;

message Test {
  gis.protobuf.Point2D point = 1;
}

生成:

protoc --python_out=. -I /usr/include/ -I . proto/test.proto

代码:

from.proto.test_pbimportTestfromgis.protobufimportPoint2Dtest=Test(point=Point2D(x=10,y=20))print(test.point.toGeoJSON())

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何避免springbootstarterparent和dependency中的flyway包冲突   java文本文件写入不起作用   java获取名为DAO类的Bean创建异常   java类路径和清单文件   如何使用Java中的模式来获取像C中的“sscanf”这样的组?   java Spring自动连接具有构造函数的类   clientSecurity运行的java geode示例失败   java JavaFX:在FXML中从ResourceBundle访问非string对象   java登录到google firebase   java对象在通过构造函数后不会更改。为什么?   java(Android)对特定页面的操作webView   javascript如何在webview的js中从java调用变量   持久化—一种在Java中存储和检索对象而不使用关系数据库的简单方法?   java Ldap获取通讯组列表中的用户   java检查温度条件   java后退按钮警报框(Android Studio)   数组java列表问题:为什么我运行它时,它会在第三次打印时打印出4?   java相对路径与绝对路径