Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xplot_server
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
digit_plot
xplot_server
Commits
d1389484
Commit
d1389484
authored
Nov 09, 2024
by
dliangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api update
parent
9e9e4267
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
100 additions
and
37 deletions
+100
-37
data/trans.go
+46
-0
geo/area.go
+9
-19
model/models.go
+32
-11
sql/area.sql
+13
-7
No files found.
data/trans.go
0 → 100644
View file @
d1389484
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
}
geo/area.go
View file @
d1389484
...
...
@@ -2,37 +2,27 @@ package geo
import
"com.dliangx.xplot/appserver/model"
func
Save
FlyDefenseRoute
(
flyDefenseRoute
*
model
.
OptRoute
)
(
string
,
error
)
{
func
Save
Route
(
line
model
.
GeoJson
,
opt_type
int
)
(
model
.
GeoJson
,
error
)
{
return
""
,
nil
return
model
.
GeoJson
{}
,
nil
}
func
Save
AgrMachRoute
(
agriMachRoute
*
model
.
OptRoute
)
(
string
,
error
)
{
func
Save
OptArea
(
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
Get
FlyDefenseRelatedArea
(
flyDefenseId
string
)
([]
string
,
error
)
{
func
Get
OptAreaRelatedAdmArea
(
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
}
model/models.go
View file @
d1389484
...
...
@@ -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"`
}
sql/area.sql
View file @
d1389484
...
...
@@ -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
(
multi
polygon
,
4326
)
geometry
geometry
(
polygon
,
4326
)
);
DROP
table
if
EXISTS
administrative_area
;
create
table
administrative_area
(
id
serial
PRIMARY
key
,
nam
e
VARCHAR
(
64
),
typ
e
VARCHAR
(
64
),
parent
int
,
properties
JSONB
,
DEGREE
int
,
area
geometry
(
multi
polygon
,
4326
)
geometry
geometry
(
polygon
,
4326
)
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment