Commit d1389484 by dliangx

api update

parent 9e9e4267
package data
import (
"fmt"
"time"
"com.dliangx.xplot/appserver/model"
)
type Msdata struct {
ID int `json:"id"`
MemberLandId int `json:"member_land_id"`
BlockCrop string `json:"block_crop"`
BlockCropVariety string `json:"block_crop_variety"`
IrrigationType string `json:"irrigation_type"`
BlockArea float64 `json:"block_area"`
BlockCoordinates string `json:"block_coordinates"`
EnclosureCoordinates string `json:"enclosure_coordinates"`
PreviewImageUrl string `json:"preview_image_url"`
BlockId int `json:"block_id"`
CreateTime string `json:"create_time"`
UpdateTime string `json:"update_time"`
}
func (data Msdata) TransToOptArea() (area model.OptArea) {
area.Properties["id"] = data.ID
area.Properties["member_land_id"] = data.MemberLandId
area.Properties["block_crop"] = data.BlockCrop
area.Properties["block_crop_variety"] = data.BlockCropVariety
area.Properties["irrigation_type"] = data.IrrigationType
area.Properties["block_area"] = data.BlockArea
area.Properties["block_coordinates"] = data.BlockCoordinates
area.Properties["preview_image_url"] = data.PreviewImageUrl
area.Properties["block_id"] = data.BlockId
area.Properties["create_time"] = data.CreateTime
area.Type = "polygon"
ptime, err := time.Parse("2006-01-02 15:04:05", data.UpdateTime)
if err != nil {
fmt.Println("时间格式错误..")
}
area.OptTime = ptime
// data.EnclosureCoordinates
fmt.Printf("area: %v\n", area)
return area
}
......@@ -2,37 +2,27 @@ package geo
import "com.dliangx.xplot/appserver/model"
func SaveFlyDefenseRoute(flyDefenseRoute *model.OptRoute) (string, error) {
func SaveRoute(line model.GeoJson, opt_type int) (model.GeoJson, error) {
return "", nil
return model.GeoJson{}, nil
}
func SaveAgrMachRoute(agriMachRoute *model.OptRoute) (string, error) {
func SaveOptArea(optArea model.GeoJson) (model.GeoJson, error) {
return "", nil
return model.GeoJson{}, nil
}
func SaveOptArea(optArea *model.OptArea) (string, error) {
func GetRouteRelatedArea(agriMach model.GeoJson) ([]model.GeoJson, error) {
return "", nil
return []model.GeoJson{}, nil
}
func GetFlyDefenseRelatedArea(flyDefenseId string) ([]string, error) {
func GetOptAreaRelatedAdmArea(optArea model.GeoJson) ([]model.GeoJson, error) {
return []string{}, nil
return []model.GeoJson{}, nil
}
func GetAgrMachRelatedArea(agriMachId string) ([]string, error) {
return []string{}, nil
}
func GetOptAreaRelatedAdmArea(optAreaId string) ([]string, error) {
return []string{}, nil
}
func CheckOptAreasCross(flyDefenseAreaId, agriMachAreaId string) (bool, error) {
func CheckOptAreasCross(flyDefenseArea, agriMachArea model.GeoJson) (bool, error) {
return false, nil
}
......@@ -6,23 +6,44 @@ import (
geojson "github.com/paulmach/go.geojson"
)
// FlyDefenseRoute 飞防路线
type OptRoute struct {
ID string `json:"id"` // 路线ID
Name string `json:"name"` // 路线名称
ID int `json:"id"` // 路线ID
Type string `json:"type"`
Properties map[string]interface{} `json:"properties"`
OptTime time.Time `json:"opt_time"`
RouteLine geojson.Geometry `json:"route_line"` // 路线坐标点 (PostGIS LineString)
Geometry *geojson.Geometry `json:"route_line"`
}
type OptFlyRoute struct {
ID int `json:"id"` // 路线ID
Type string `json:"type"`
Properties map[string]interface{} `json:"properties"`
OptTime time.Time `json:"opt_time"`
Geometry *geojson.Geometry `json:"route_line"`
}
// OptArea 作业区域
type OptArea struct {
ID string `json:"id"` // 区域ID
Name string `json:"name"` // 区域名称
Type string `json:"type"`
Properties map[string]interface{} `json:"properties"`
OptTime time.Time `json:"opt_time"`
Area geojson.Geometry `json:"area"` // 区域边界坐标点
RelatedAdmDds []string
ID int `json:"id"` // 区域ID
Type string `json:"type"`
Properties map[string]interface{} `json:"properties"`
OptTime time.Time `json:"opt_time"`
Geometry *geojson.Geometry `json:"area"` // 区域边界坐标点
}
type AdministrativeArea struct {
ID int `json:"id"` // 区域ID
Type string `json:"type"`
Parent int //所属上级区域
DEGREE int //划分等级
Properties map[string]interface{} `json:"properties"`
OptTime time.Time `json:"opt_time"`
Geometry *geojson.Geometry `json:"area"` // 区域边界坐标点
}
type GeoJson struct {
ID int `json:"id"`
Type string `json:"type"`
Properties map[string]interface{} `json:"properties"`
Geometry *geojson.Geometry `json:"geometry"`
}
......@@ -2,30 +2,36 @@
DROP table if EXISTS opt_routes;
create table opt_routes (
id serial PRIMARY key,
name VARCHAR(64),
type VARCHAR(64),
properties JSONB,
opt_time date,
route_line geometry(linestring,4326)
geometry geometry(linestring,4326)
);
DROP table if EXISTS opt_routes;
create table opt_fly_routes (
id serial PRIMARY key,
type VARCHAR(64),
properties JSONB,
opt_time date,
geometry geometry(linestring,4326)
);
drop table if EXISTS opt_area ;
create table opt_area(
id serial PRIMARY key,
name VARCHAR(64),
type VARCHAR(64),
properties JSONB,
related_adm_ids text[],
opt_time date,
area geometry(multipolygon,4326)
geometry geometry(polygon,4326)
);
DROP table if EXISTS administrative_area;
create table administrative_area(
id serial PRIMARY key,
name VARCHAR(64),
type VARCHAR(64),
parent int,
properties JSONB,
DEGREE int,
area geometry(multipolygon,4326)
geometry geometry(polygon,4326)
);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment