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
d5cbaec9
Commit
d5cbaec9
authored
Nov 09, 2024
by
dliangx
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
圈地数据导入
parent
503ff447
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
867 additions
and
3 deletions
+867
-3
data/testdata/data.json
+661
-0
data/trans.go
+118
-3
data/trans_test.go
+88
-0
No files found.
data/testdata/data.json
0 → 100644
View file @
d5cbaec9
[
{
"id"
:
5
,
"member_land_id"
:
4
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
100.0000
,
"block_coordinates"
:
"112.815624,37.460469"
,
"enclosure_coordinates"
:
"[[[112.814746,37.459434],[112.813547,37.460806],[112.814086,37.462012],[112.815706,37.461738],[112.816799,37.461269],[112.817074,37.460346],[112.816888,37.45944],[112.816145,37.458709]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
10
,
"create_time"
:
"2024-04-02 11:19:44"
,
"update_time"
:
"2024-04-10 18:06:51"
},
{
"id"
:
6
,
"member_land_id"
:
5
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
100.0000
,
"block_coordinates"
:
"116.388101,39.927367"
,
"enclosure_coordinates"
:
"[[[116.385033,39.928025],[116.390224,39.929196],[116.389046,39.924881]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-05 13:46:53"
,
"update_time"
:
"2024-04-05 13:46:53"
},
{
"id"
:
10
,
"member_land_id"
:
9
,
"block_crop"
:
"其他"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
268.0000
,
"block_coordinates"
:
"121.473129,31.231325"
,
"enclosure_coordinates"
:
"[[[121.472252,31.232137],[121.473797,31.232495],[121.47428,31.230559],[121.472188,31.23011]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
11
,
"create_time"
:
"2024-04-06 16:32:05"
,
"update_time"
:
"2024-04-10 18:07:46"
},
{
"id"
:
11
,
"member_land_id"
:
10
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
10.0000
,
"block_coordinates"
:
"114.054545,39.73153"
,
"enclosure_coordinates"
:
"[[[114.054731,39.731617],[114.055636,39.731349],[114.055535,39.731008],[114.053346,39.731722],[114.053475,39.731955]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
9
,
"create_time"
:
"2024-04-06 21:30:44"
,
"update_time"
:
"2024-04-10 17:47:19"
},
{
"id"
:
12
,
"member_land_id"
:
11
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
120.0000
,
"block_coordinates"
:
"111.994958,37.33439"
,
"enclosure_coordinates"
:
"[[[111.993759,37.33582],[111.997491,37.335273],[111.995318,37.333235],[111.993265,37.333233]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-08 14:52:23"
,
"update_time"
:
"2024-04-08 14:52:23"
},
{
"id"
:
13
,
"member_land_id"
:
11
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
53.0000
,
"block_coordinates"
:
"111.988112,37.345063"
,
"enclosure_coordinates"
:
"[[[111.986868,37.344282],[111.987274,37.346078],[111.989276,37.345833],[111.989032,37.344059]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-08 14:52:23"
,
"update_time"
:
"2024-04-08 14:52:23"
},
{
"id"
:
14
,
"member_land_id"
:
12
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
100.0000
,
"block_coordinates"
:
"112.247928,37.22615"
,
"enclosure_coordinates"
:
"[[[112.247112,37.227145],[112.248635,37.227169],[112.248701,37.225153],[112.247263,37.225133]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
12
,
"create_time"
:
"2024-04-08 17:21:09"
,
"update_time"
:
"2024-04-10 18:18:50"
},
{
"id"
:
15
,
"member_land_id"
:
13
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
20.0000
,
"block_coordinates"
:
"112.247189,37.224669"
,
"enclosure_coordinates"
:
"[[[112.246267,37.225047],[112.248035,37.225087],[112.2481,37.224341],[112.246354,37.224202]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
13
,
"create_time"
:
"2024-04-08 17:26:05"
,
"update_time"
:
"2024-04-10 18:21:27"
},
{
"id"
:
18
,
"member_land_id"
:
16
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
180.0000
,
"block_coordinates"
:
"112.844937,35.313507"
,
"enclosure_coordinates"
:
"[[[112.846969,35.308014],[112.841846,35.311522],[112.845327,35.31439],[112.845368,35.313934],[112.845041,35.31389],[112.844986,35.313807],[112.844912,35.313873],[112.844939,35.313945],[112.84498,35.314001],[112.844843,35.31394],[112.844905,35.314034],[112.84483,35.313895],[112.845211,35.313957],[112.84485,35.313862],[112.845014,35.314023],[112.845055,35.314185],[112.844891,35.313923],[112.844891,35.313929]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
17
,
"create_time"
:
"2024-04-09 15:14:52"
,
"update_time"
:
"2024-04-10 18:31:39"
},
{
"id"
:
19
,
"member_land_id"
:
17
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
2000.0000
,
"block_coordinates"
:
"114.290829,39.824694"
,
"enclosure_coordinates"
:
"[[[114.282504,39.826302],[114.284838,39.826513],[114.28581,39.826512],[114.286258,39.827002],[114.287265,39.82739],[114.288182,39.828812],[114.288936,39.828906],[114.289297,39.829224],[114.289084,39.829937],[114.289564,39.830537],[114.290548,39.830651],[114.291176,39.830709],[114.291919,39.830051],[114.29223,39.829493],[114.292705,39.829564],[114.293317,39.829447],[114.293492,39.828843],[114.294448,39.828625],[114.294715,39.828281],[114.294595,39.829468],[114.297181,39.829827],[114.297356,39.829643],[114.297268,39.829378],[114.298121,39.828909],[114.298317,39.828376],[114.298202,39.827906],[114.297962,39.827411],[114.297653,39.826462],[114.29827,39.825619],[114.298363,39.825208],[114.298354,39.824056],[114.2986,39.823183],[114.298431,39.821836],[114.296963,39.821172],[114.296149,39.820488],[114.293984,39.819895],[114.29323,39.817608],[114.290464,39.817629],[114.290824,39.819563],[114.288998,39.819639],[114.287785,39.819622],[114.287753,39.819261],[114.287835,39.818703],[114.287736,39.818494],[114.287348,39.818439],[114.286742,39.818464],[114.286338,39.818431],[114.285726,39.818464],[114.285437,39.818485],[114.284967,39.819257],[114.283773,39.819841],[114.283003,39.820907],[114.282353,39.82183],[114.281541,39.822951],[114.280968,39.824277],[114.281569,39.825376]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-09 17:59:03"
,
"update_time"
:
"2024-04-09 17:59:03"
},
{
"id"
:
20
,
"member_land_id"
:
17
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
100.0000
,
"block_coordinates"
:
"114.292615,39.819701"
,
"enclosure_coordinates"
:
"[[[114.29221,39.821484],[114.293108,39.821502],[114.294237,39.82146],[114.294245,39.820978],[114.294241,39.820981],[114.293897,39.819909],[114.293618,39.818874],[114.293286,39.817674],[114.292249,39.817549],[114.290561,39.817638],[114.291026,39.818173],[114.291374,39.818714],[114.291684,39.819267],[114.292442,39.819582],[114.292439,39.819597],[114.292249,39.82001],[114.292109,39.820408],[114.292101,39.820812]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-09 17:59:03"
,
"update_time"
:
"2024-04-09 17:59:03"
},
{
"id"
:
21
,
"member_land_id"
:
18
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
13.0000
,
"block_coordinates"
:
"112.526393,37.550877"
,
"enclosure_coordinates"
:
"[[[112.525861,37.551266],[112.526921,37.551356],[112.526933,37.550465],[112.525855,37.550422]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
14
,
"create_time"
:
"2024-04-09 20:50:06"
,
"update_time"
:
"2024-04-10 18:25:19"
},
{
"id"
:
22
,
"member_land_id"
:
18
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
6.0000
,
"block_coordinates"
:
"112.520417,37.545017"
,
"enclosure_coordinates"
:
"[[[112.519192,37.545599],[112.519315,37.544335],[112.521474,37.545521],[112.521046,37.544082],[112.520721,37.54503],[112.520677,37.545057],[112.520377,37.54515],[112.520382,37.54515],[112.520502,37.545126],[112.520484,37.545123]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
15
,
"create_time"
:
"2024-04-09 20:50:06"
,
"update_time"
:
"2024-04-10 18:25:19"
},
{
"id"
:
23
,
"member_land_id"
:
18
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
6.0000
,
"block_coordinates"
:
"112.518564,37.546607"
,
"enclosure_coordinates"
:
"[[[112.518367,37.546995],[112.518968,37.546953],[112.518877,37.546207],[112.518406,37.546227],[112.518391,37.546977],[112.518377,37.546282]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
16
,
"create_time"
:
"2024-04-09 20:50:06"
,
"update_time"
:
"2024-04-10 18:25:19"
},
{
"id"
:
24
,
"member_land_id"
:
19
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
1000.0000
,
"block_coordinates"
:
"113.613617,34.921522"
,
"enclosure_coordinates"
:
"[[[113.613676,34.921432],[113.613394,34.921757],[113.613824,34.92188],[113.614049,34.92152],[113.614092,34.9213],[113.613588,34.921133],[113.61348,34.920957],[113.613266,34.921713],[113.613491,34.921757],[113.613309,34.921775]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
8
,
"create_time"
:
"2024-04-10 08:24:56"
,
"update_time"
:
"2024-04-10 17:38:54"
},
{
"id"
:
25
,
"member_land_id"
:
20
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
null
,
"irrigation_type"
:
null
,
"block_area"
:
180.0000
,
"block_coordinates"
:
"112.587159,37.764017"
,
"enclosure_coordinates"
:
"[[[112.586081,37.765295],[112.589449,37.765285],[112.589045,37.76298],[112.585953,37.762753],[112.586266,37.76352],[112.586162,37.764267]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-10 18:31:43"
,
"update_time"
:
"2024-04-10 18:31:43"
},
{
"id"
:
27
,
"member_land_id"
:
22
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"大丰FD899"
,
"irrigation_type"
:
"滴灌"
,
"block_area"
:
2000.0000
,
"block_coordinates"
:
"114.290902,39.823729"
,
"enclosure_coordinates"
:
"[[[114.283731,39.819731],[114.283009,39.821143],[114.282076,39.82239],[114.2812,39.824347],[114.281109,39.824905],[114.281696,39.825398],[114.281877,39.825969],[114.282792,39.826802],[114.283695,39.826989],[114.284442,39.826406],[114.284962,39.826457],[114.285323,39.826765],[114.286869,39.827152],[114.287799,39.827963],[114.288854,39.828073],[114.289363,39.828084],[114.290026,39.828189],[114.290717,39.828443],[114.291545,39.828842],[114.292399,39.829193],[114.292701,39.829166],[114.293187,39.829321],[114.293511,39.8294],[114.29417,39.829553],[114.294563,39.829506],[114.295496,39.829554],[114.296521,39.82966],[114.297274,39.829722],[114.297321,39.829246],[114.298044,39.828894],[114.29796,39.828449],[114.298106,39.827903],[114.297911,39.827393],[114.297495,39.827469],[114.297461,39.827142],[114.297695,39.826787],[114.297633,39.826349],[114.29819,39.82563],[114.298327,39.825128],[114.298466,39.824583],[114.298507,39.823541],[114.298515,39.82259],[114.298435,39.821737],[114.298066,39.821474],[114.297143,39.82113],[114.296378,39.820554],[114.295093,39.820071],[114.294133,39.819819],[114.293891,39.819308],[114.293605,39.818366],[114.293204,39.817524],[114.29041,39.817585],[114.289666,39.817558],[114.290311,39.818142],[114.290538,39.818561],[114.29018,39.818408],[114.289327,39.818399],[114.288728,39.818446],[114.288873,39.819148],[114.287817,39.819249],[114.287806,39.818916],[114.287786,39.81851],[114.286781,39.81844],[114.286788,39.818808],[114.286271,39.818988],[114.286028,39.819267],[114.285826,39.819197],[114.285267,39.819215],[114.284615,39.819343],[114.284442,39.819164],[114.284096,39.819211]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
18
,
"create_time"
:
"2024-04-10 20:10:10"
,
"update_time"
:
"2024-04-11 08:17:04"
},
{
"id"
:
28
,
"member_land_id"
:
22
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"待定"
,
"irrigation_type"
:
"滴灌"
,
"block_area"
:
100.0000
,
"block_coordinates"
:
"114.29259,39.81924"
,
"enclosure_coordinates"
:
"[[[114.29056,39.817508],[114.290853,39.818065],[114.291259,39.818755],[114.291738,39.819281],[114.292375,39.8196],[114.292422,39.820012],[114.29201,39.820088],[114.292103,39.820986],[114.293975,39.820766],[114.294028,39.820723],[114.293884,39.820031],[114.293761,39.81918],[114.293443,39.818442],[114.293311,39.817718],[114.293122,39.817449]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
19
,
"create_time"
:
"2024-04-10 20:10:10"
,
"update_time"
:
"2024-04-11 08:17:04"
},
{
"id"
:
29
,
"member_land_id"
:
23
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"未定"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
300.0000
,
"block_coordinates"
:
"111.088914,37.414823"
,
"enclosure_coordinates"
:
"[[[111.088187,37.420738],[111.088828,37.421128],[111.090889,37.415748],[111.089945,37.415427],[111.089945,37.414249],[111.090298,37.413305],[111.086405,37.410171],[111.08597,37.410761],[111.088031,37.412432],[111.089523,37.413302],[111.090028,37.415792]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
20
,
"create_time"
:
"2024-04-11 17:52:55"
,
"update_time"
:
"2024-04-11 17:54:09"
},
{
"id"
:
32
,
"member_land_id"
:
26
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"黄金粮MY73"
,
"irrigation_type"
:
"漫灌"
,
"block_area"
:
100.0000
,
"block_coordinates"
:
"109.481039,34.819062"
,
"enclosure_coordinates"
:
"[[[109.479266,34.819985],[109.482663,34.820502],[109.482753,34.818141],[109.479474,34.81762]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
24
,
"create_time"
:
"2024-04-13 09:27:34"
,
"update_time"
:
"2024-04-15 11:04:23"
},
{
"id"
:
33
,
"member_land_id"
:
26
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"黄金粮MY73"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
100.0000
,
"block_coordinates"
:
"110.456377,34.884491"
,
"enclosure_coordinates"
:
"[[[110.455626,34.886032],[110.457278,34.88597],[110.457783,34.883148],[110.454822,34.882816]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
25
,
"create_time"
:
"2024-04-13 09:27:34"
,
"update_time"
:
"2024-04-15 11:04:23"
},
{
"id"
:
34
,
"member_land_id"
:
27
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"1"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
1200.0000
,
"block_coordinates"
:
"113.642534,39.689431"
,
"enclosure_coordinates"
:
"[[[113.638314,39.684795],[113.6371,39.692529],[113.646181,39.694333],[113.648539,39.686069]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
23
,
"create_time"
:
"2024-04-15 09:14:42"
,
"update_time"
:
"2024-04-15 09:49:45"
},
{
"id"
:
35
,
"member_land_id"
:
28
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
160.0000
,
"block_coordinates"
:
"113.014841,38.553835"
,
"enclosure_coordinates"
:
"[[[113.012641,38.552479],[113.012542,38.555043],[113.016954,38.555116],[113.017228,38.552702]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-15 12:32:16"
,
"update_time"
:
"2024-04-15 12:32:16"
},
{
"id"
:
36
,
"member_land_id"
:
29
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
160.0000
,
"block_coordinates"
:
"113.015059,38.553838"
,
"enclosure_coordinates"
:
"[[[113.012727,38.552405],[113.012849,38.55516],[113.017303,38.555053],[113.017359,38.552735]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-15 12:35:15"
,
"update_time"
:
"2024-04-15 12:35:15"
},
{
"id"
:
37
,
"member_land_id"
:
30
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
160.0000
,
"block_coordinates"
:
"113.014862,38.553929"
,
"enclosure_coordinates"
:
"[[[113.012691,38.552507],[113.012636,38.555184],[113.016979,38.555234],[113.017143,38.552792]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
26
,
"create_time"
:
"2024-04-15 12:37:49"
,
"update_time"
:
"2024-04-15 14:25:58"
},
{
"id"
:
38
,
"member_land_id"
:
31
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"1715"
,
"irrigation_type"
:
"渠浇"
,
"block_area"
:
50.0000
,
"block_coordinates"
:
"112.970299,38.509377"
,
"enclosure_coordinates"
:
"[[[112.974148,38.509344],[112.974286,38.510315],[112.970553,38.509888],[112.968611,38.509767],[112.967549,38.508949],[112.967882,38.508499],[112.969061,38.508878]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
27
,
"create_time"
:
"2024-04-15 12:55:30"
,
"update_time"
:
"2024-04-16 09:11:37"
},
{
"id"
:
39
,
"member_land_id"
:
32
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
10.0000
,
"block_coordinates"
:
"113.056846,38.526626"
,
"enclosure_coordinates"
:
"[[[113.056763,38.527318],[113.05728,38.527164],[113.056925,38.525977],[113.056417,38.526045]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
29
,
"create_time"
:
"2024-04-15 21:02:47"
,
"update_time"
:
"2024-04-17 09:08:19"
},
{
"id"
:
40
,
"member_land_id"
:
33
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
10.0000
,
"block_coordinates"
:
"113.056833,38.526534"
,
"enclosure_coordinates"
:
"[[[113.057242,38.5272],[113.057178,38.526657],[113.056976,38.525946],[113.056266,38.526033],[113.056502,38.526835]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
28
,
"create_time"
:
"2024-04-16 10:53:36"
,
"update_time"
:
"2024-04-17 09:08:12"
},
{
"id"
:
41
,
"member_land_id"
:
34
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
100.0000
,
"block_coordinates"
:
"113.00224,38.551256"
,
"enclosure_coordinates"
:
"[[[113.00085,38.552742],[113.003869,38.552789],[113.004112,38.550594],[113.002508,38.550493],[113.001119,38.550459],[113.000979,38.550457]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-18 11:23:19"
,
"update_time"
:
"2024-04-18 11:23:19"
},
{
"id"
:
42
,
"member_land_id"
:
35
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"滴灌"
,
"block_area"
:
70.0000
,
"block_coordinates"
:
"113.051203,38.615659"
,
"enclosure_coordinates"
:
"[[[113.051372,38.616775],[113.05134,38.615809],[113.051533,38.615732],[113.051682,38.614583],[113.050673,38.614302],[113.05062,38.61675]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-18 14:10:32"
,
"update_time"
:
"2024-04-18 14:10:32"
},
{
"id"
:
43
,
"member_land_id"
:
36
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"滴灌"
,
"block_area"
:
70.0000
,
"block_coordinates"
:
"113.05007,38.620963"
,
"enclosure_coordinates"
:
"[[[113.051156,38.62059],[113.051059,38.621257],[113.050267,38.621245],[113.048905,38.621143],[113.048961,38.620579]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-19 09:47:57"
,
"update_time"
:
"2024-04-19 09:47:57"
},
{
"id"
:
44
,
"member_land_id"
:
37
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
100.0000
,
"block_coordinates"
:
"113.014629,38.54498"
,
"enclosure_coordinates"
:
"[[[113.009513,38.545273],[113.019594,38.545368],[113.019759,38.544898],[113.009652,38.544379]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-19 10:40:51"
,
"update_time"
:
"2024-04-19 10:40:51"
},
{
"id"
:
45
,
"member_land_id"
:
38
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先王1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
7.0000
,
"block_coordinates"
:
"113.009032,38.505007"
,
"enclosure_coordinates"
:
"[[[113.009952,38.50488],[113.007936,38.50489],[113.008204,38.505156],[113.010035,38.505101]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-19 20:34:44"
,
"update_time"
:
"2024-04-19 20:34:44"
},
{
"id"
:
46
,
"member_land_id"
:
39
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
30.0000
,
"block_coordinates"
:
"121.461257,31.209986"
,
"enclosure_coordinates"
:
"[[[121.462546,31.210334],[121.46199,31.209467],[121.460699,31.209411],[121.460296,31.209956],[121.460753,31.210763]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-19 21:15:08"
,
"update_time"
:
"2024-04-19 21:15:08"
},
{
"id"
:
47
,
"member_land_id"
:
40
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
20.0000
,
"block_coordinates"
:
"113.009724,38.536181"
,
"enclosure_coordinates"
:
"[[[113.010307,38.536991],[113.010208,38.535333],[113.00907,38.535337],[113.009311,38.537065]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-19 21:19:28"
,
"update_time"
:
"2024-04-19 21:19:28"
},
{
"id"
:
48
,
"member_land_id"
:
41
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
30.0000
,
"block_coordinates"
:
"112.899382,38.569572"
,
"enclosure_coordinates"
:
"[[[112.900402,38.569651],[112.899667,38.568684],[112.898535,38.569441],[112.898922,38.570513]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-20 12:03:01"
,
"update_time"
:
"2024-04-20 12:03:01"
},
{
"id"
:
49
,
"member_land_id"
:
42
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
20.0000
,
"block_coordinates"
:
"112.922679,38.517462"
,
"enclosure_coordinates"
:
"[[[112.921733,38.517774],[112.921782,38.516974],[112.923659,38.517211],[112.923543,38.51789]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-21 09:59:15"
,
"update_time"
:
"2024-04-21 09:59:15"
},
{
"id"
:
50
,
"member_land_id"
:
43
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
70.0000
,
"block_coordinates"
:
"112.932263,38.551861"
,
"enclosure_coordinates"
:
"[[[112.930795,38.552584],[112.933658,38.552851],[112.93371,38.551065],[112.930889,38.550945]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-04-22 09:52:10"
,
"update_time"
:
"2024-04-22 09:52:10"
},
{
"id"
:
51
,
"member_land_id"
:
44
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"先玉1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
40.0000
,
"block_coordinates"
:
"112.832515,38.6383"
,
"enclosure_coordinates"
:
"[[[112.831478,38.638983],[112.833622,38.638915],[112.833526,38.637642],[112.831435,38.637659]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-05-01 22:21:13"
,
"update_time"
:
"2024-05-01 22:21:13"
},
{
"id"
:
52
,
"member_land_id"
:
45
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"1715"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
100.0000
,
"block_coordinates"
:
"113.002439,38.551671"
,
"enclosure_coordinates"
:
"[[[113.000872,38.550598],[113.000872,38.552754],[113.003963,38.552813],[113.004049,38.550519]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-05-01 22:39:00"
,
"update_time"
:
"2024-05-01 22:39:00"
},
{
"id"
:
53
,
"member_land_id"
:
46
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"几"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
2.0000
,
"block_coordinates"
:
"108.938077,34.341778"
,
"enclosure_coordinates"
:
"[[[108.937071,34.342356],[108.937146,34.340921],[108.938959,34.341133],[108.939131,34.342701]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-05-10 16:55:26"
,
"update_time"
:
"2024-05-10 16:55:26"
},
{
"id"
:
55
,
"member_land_id"
:
47
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"福园二号"
,
"irrigation_type"
:
"渠浇"
,
"block_area"
:
12.0000
,
"block_coordinates"
:
"112.41356,37.569534"
,
"enclosure_coordinates"
:
"[[[112.41208,37.570153],[112.415061,37.570026],[112.415092,37.568822],[112.412007,37.569134]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-07-29 11:44:18"
,
"update_time"
:
"2024-07-29 11:44:18"
},
{
"id"
:
75
,
"member_land_id"
:
50
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"12"
,
"irrigation_type"
:
"井浇"
,
"block_area"
:
2536.0000
,
"block_coordinates"
:
"121.473496,31.230662"
,
"enclosure_coordinates"
:
"[[[121.472859,31.229731],[121.472925,31.228189],[121.474729,31.22852],[121.473647,31.232439],[121.472684,31.231435]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-08-01 13:37:37"
,
"update_time"
:
"2024-08-01 13:37:37"
},
{
"id"
:
89
,
"member_land_id"
:
48
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"1"
,
"irrigation_type"
:
"漫灌"
,
"block_area"
:
10.0000
,
"block_coordinates"
:
"112.333523,37.470918"
,
"enclosure_coordinates"
:
"[[[112.341094,37.472028],[112.340319,37.472173],[112.340031,37.471299],[112.34085,37.471146]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-08-02 16:49:57"
,
"update_time"
:
"2024-08-02 16:49:57"
},
{
"id"
:
90
,
"member_land_id"
:
48
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"1"
,
"irrigation_type"
:
"滴灌"
,
"block_area"
:
10.0000
,
"block_coordinates"
:
"112.335668,37.470836"
,
"enclosure_coordinates"
:
"[[[112.341057,37.473447],[112.34077,37.472557],[112.341517,37.47246],[112.341788,37.473364]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-08-02 16:49:57"
,
"update_time"
:
"2024-08-02 16:49:57"
},
{
"id"
:
91
,
"member_land_id"
:
48
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"1"
,
"irrigation_type"
:
"滴灌"
,
"block_area"
:
4.0000
,
"block_coordinates"
:
"112.335668,37.470836"
,
"enclosure_coordinates"
:
"[[[112.34141,37.473399],[112.34189,37.473358],[112.342114,37.473944],[112.34164,37.473983]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-08-02 16:49:57"
,
"update_time"
:
"2024-08-02 16:49:57"
},
{
"id"
:
93
,
"member_land_id"
:
49
,
"block_crop"
:
"玉米"
,
"block_crop_variety"
:
"40"
,
"irrigation_type"
:
"渠浇"
,
"block_area"
:
20.0000
,
"block_coordinates"
:
"121.452578,31.166"
,
"enclosure_coordinates"
:
"[[[121.452555,31.166685],[121.451878,31.165443],[121.45316,31.165512]],[[121.452667,31.165034],[121.451687,31.164631],[121.451961,31.163511],[121.452722,31.163295],[121.453094,31.163416],[121.453471,31.163625],[121.453625,31.164101],[121.453561,31.164628]],[[121.452684,31.162707],[121.452221,31.161712],[121.453072,31.161409],[121.453443,31.161784],[121.453392,31.162245],[121.45304,31.162489]]]"
,
"preview_image_url"
:
null
,
"block_id"
:
null
,
"create_time"
:
"2024-08-05 12:06:15"
,
"update_time"
:
"2024-08-05 12:06:15"
}
]
\ No newline at end of file
data/trans.go
View file @
d5cbaec9
package
data
package
data
import
(
import
(
"database/sql"
"encoding/json"
"fmt"
"fmt"
"log"
"os"
"strings"
"time"
"time"
"com.dliangx.xplot/appserver/model"
"com.dliangx.xplot/appserver/model"
geojson
"github.com/paulmach/go.geojson"
)
)
type
Msdata
struct
{
type
Msdata
struct
{
...
@@ -23,6 +29,8 @@ type Msdata struct {
...
@@ -23,6 +29,8 @@ type Msdata struct {
}
}
func
(
data
Msdata
)
TransToOptArea
()
(
area
model
.
OptArea
)
{
func
(
data
Msdata
)
TransToOptArea
()
(
area
model
.
OptArea
)
{
// 设置基本属性
area
.
Properties
=
make
(
map
[
string
]
interface
{})
area
.
Properties
[
"id"
]
=
data
.
ID
area
.
Properties
[
"id"
]
=
data
.
ID
area
.
Properties
[
"member_land_id"
]
=
data
.
MemberLandId
area
.
Properties
[
"member_land_id"
]
=
data
.
MemberLandId
area
.
Properties
[
"block_crop"
]
=
data
.
BlockCrop
area
.
Properties
[
"block_crop"
]
=
data
.
BlockCrop
...
@@ -33,14 +41,121 @@ func (data Msdata) TransToOptArea() (area model.OptArea) {
...
@@ -33,14 +41,121 @@ func (data Msdata) TransToOptArea() (area model.OptArea) {
area
.
Properties
[
"preview_image_url"
]
=
data
.
PreviewImageUrl
area
.
Properties
[
"preview_image_url"
]
=
data
.
PreviewImageUrl
area
.
Properties
[
"block_id"
]
=
data
.
BlockId
area
.
Properties
[
"block_id"
]
=
data
.
BlockId
area
.
Properties
[
"create_time"
]
=
data
.
CreateTime
area
.
Properties
[
"create_time"
]
=
data
.
CreateTime
// 设置类型
area
.
Type
=
"polygon"
area
.
Type
=
"polygon"
// 解析更新时间
ptime
,
err
:=
time
.
Parse
(
"2006-01-02 15:04:05"
,
data
.
UpdateTime
)
ptime
,
err
:=
time
.
Parse
(
"2006-01-02 15:04:05"
,
data
.
UpdateTime
)
if
err
!=
nil
{
if
err
!=
nil
{
fmt
.
Println
(
"时间格式错误
.."
)
fmt
.
Println
(
"时间格式错误
:"
,
err
)
}
}
area
.
OptTime
=
ptime
area
.
OptTime
=
ptime
// data.EnclosureCoordinates
// 解析围栏坐标为geometry
fmt
.
Printf
(
"area: %v
\n
"
,
area
)
geometry
,
err
:=
data
.
parseEnclosureCoordinates
()
if
err
!=
nil
{
fmt
.
Println
(
"解析围栏坐标错误:"
,
err
)
area
.
Geometry
=
nil
}
else
{
area
.
Geometry
=
geometry
}
return
area
return
area
}
}
func
(
data
Msdata
)
parseEnclosureCoordinates
()
(
*
geojson
.
Geometry
,
error
)
{
// 移除空格
coordStr
:=
strings
.
TrimSpace
(
data
.
EnclosureCoordinates
)
// 创建geometry结构
geometry
:=
&
geojson
.
Geometry
{
Type
:
"Polygon"
,
}
// 解析坐标字符串
var
coordinates
[][][]
float64
if
err
:=
json
.
Unmarshal
([]
byte
(
coordStr
),
&
coordinates
);
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"解��坐标失败: %v"
,
err
)
}
// 设置坐标
geometry
.
Polygon
=
coordinates
return
geometry
,
nil
}
// ProcessJsonData 处理JSON数据并写入数据库
func
ProcessJsonData
(
jsonData
[]
byte
,
db
*
sql
.
DB
)
error
{
// 开始事务
tx
,
err
:=
db
.
Begin
()
if
err
!=
nil
{
return
fmt
.
Errorf
(
"开始事务失败: %v"
,
err
)
}
defer
tx
.
Rollback
()
// 解析JSON数据
var
msdataList
[]
Msdata
if
err
:=
json
.
Unmarshal
(
jsonData
,
&
msdataList
);
err
!=
nil
{
return
fmt
.
Errorf
(
"解析JSON失败: %v"
,
err
)
}
// 处理每条记录
for
_
,
msdata
:=
range
msdataList
{
optArea
:=
msdata
.
TransToOptArea
()
// 将 Properties 和 Geometry 转换为 JSON
propertiesJSON
,
err
:=
json
.
Marshal
(
optArea
.
Properties
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Properties转JSON失败: %v"
,
err
)
}
geometryJSON
,
err
:=
json
.
Marshal
(
optArea
.
Geometry
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"Geometry转JSON失败: %v"
,
err
)
}
// 写入数据库
_
,
err
=
tx
.
Exec
(
`
INSERT INTO opt_areas (
type,
properties,
geometry,
opt_time
) VALUES ($1, $2, $3, $4)
`
,
optArea
.
Type
,
propertiesJSON
,
// 使用JSON格式
geometryJSON
,
// 使用JSON格式
optArea
.
OptTime
,
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"插入数据失败: %v"
,
err
)
}
}
// 提交事务
if
err
:=
tx
.
Commit
();
err
!=
nil
{
return
fmt
.
Errorf
(
"提交事务失败: %v"
,
err
)
}
return
nil
}
// ProcessJsonFile 从文件读取并处理JSON数据
func
ProcessJsonFile
(
filePath
string
,
db
*
sql
.
DB
)
error
{
// 读取JSON文件
jsonData
,
err
:=
os
.
ReadFile
(
filePath
)
if
err
!=
nil
{
return
fmt
.
Errorf
(
"读取JSON文件失败: %v"
,
err
)
}
// 使用已有的ProcessJsonData处理数据
if
err
:=
ProcessJsonData
(
jsonData
,
db
);
err
!=
nil
{
return
fmt
.
Errorf
(
"处理数据失败: %v"
,
err
)
}
log
.
Printf
(
"成功处理文件: %s"
,
filePath
)
return
nil
}
data/trans_test.go
0 → 100644
View file @
d5cbaec9
package
data
import
(
"database/sql"
"os"
"path/filepath"
"testing"
_
"github.com/lib/pq"
)
func
TestProcessJsonFile
(
t
*
testing
.
T
)
{
// 设置测试数据库连接
dbURL
:=
os
.
Getenv
(
"TEST_DATABASE_URL"
)
if
dbURL
==
""
{
dbURL
=
"postgres://liang:postgres@localhost/xpolt?sslmode=disable"
}
// 连接数据库
db
,
err
:=
sql
.
Open
(
"postgres"
,
dbURL
)
if
err
!=
nil
{
t
.
Fatalf
(
"数据库连接失败: %v"
,
err
)
}
defer
db
.
Close
()
// 测试数据库连接
if
err
:=
db
.
Ping
();
err
!=
nil
{
t
.
Fatalf
(
"数据库连接测试失败: %v"
,
err
)
}
// 获取测试文件路径
testFile
:=
filepath
.
Join
(
"testdata"
,
"data.json"
)
// 测试文件处理
err
=
ProcessJsonFile
(
testFile
,
db
)
if
err
!=
nil
{
t
.
Errorf
(
"处理JSON文件失败: %v"
,
err
)
}
}
func
TestMsdataTransToOptArea
(
t
*
testing
.
T
)
{
// 创建测试数据
testData
:=
Msdata
{
ID
:
1
,
MemberLandId
:
4
,
BlockCrop
:
"玉米"
,
BlockArea
:
100.0000
,
BlockCoordinates
:
"112.815624,37.460469"
,
EnclosureCoordinates
:
`[[[112.814746,37.459434],[112.813547,37.460806],
[112.814086,37.462012],[112.815706,37.461738],[112.816799,37.461269],
[112.817074,37.460346],[112.816888,37.45944],[112.816145,37.458709]]]`
,
CreateTime
:
"2024-04-02 11:19:44"
,
UpdateTime
:
"2024-04-10 18:06:51"
,
}
// 测试转换
optArea
:=
testData
.
TransToOptArea
()
// 验证转换结果
if
optArea
.
Type
!=
"polygon"
{
t
.
Errorf
(
"期望类型为 polygon, 得到 %s"
,
optArea
.
Type
)
}
if
optArea
.
Properties
[
"id"
]
!=
testData
.
ID
{
t
.
Errorf
(
"期望 ID 为 %d, 得到 %v"
,
testData
.
ID
,
optArea
.
Properties
[
"id"
])
}
if
optArea
.
Geometry
==
nil
{
t
.
Error
(
"Geometry 不应该为 nil"
)
}
}
func
TestParseEnclosureCoordinates
(
t
*
testing
.
T
)
{
testData
:=
Msdata
{
EnclosureCoordinates
:
`[[[112.814746,37.459434],[112.813547,37.460806],
[112.814086,37.462012],[112.815706,37.461738]]]`
,
}
geometry
,
err
:=
testData
.
parseEnclosureCoordinates
()
if
err
!=
nil
{
t
.
Errorf
(
"解析坐标失败: %v"
,
err
)
}
if
geometry
.
Type
!=
"Polygon"
{
t
.
Errorf
(
"期望类型为 Polygon, 得到 %s"
,
geometry
.
Type
)
}
}
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