@@ -23,21 +23,6 @@ import {
23
23
createPostRequestSpy ,
24
24
createResponseSpy ,
25
25
} from './testing/http-test-helpers' ;
26
- import {
27
- $job_id ,
28
- $geometry ,
29
- $submission_count ,
30
- $source ,
31
- $properties ,
32
- $point ,
33
- $polygon ,
34
- $multi_polygon ,
35
- $shell ,
36
- $coordinates ,
37
- $polygons ,
38
- $latitude ,
39
- $longitude ,
40
- } from '@ground/lib/dist/testing/proto-field-aliases' ;
41
26
import { importGeoJsonCallback } from './import-geojson' ;
42
27
import { DecodedIdToken } from 'firebase-admin/auth' ;
43
28
import { Blob , FormData } from 'formdata-node' ;
@@ -46,6 +31,17 @@ import {invokeCallbackAsync} from './handlers';
46
31
import { OWNER_ROLE } from './common/auth' ;
47
32
import { resetDatastore } from './common/context' ;
48
33
import { Firestore } from 'firebase-admin/firestore' ;
34
+ import { registry } from '@ground/lib' ;
35
+ import { GroundProtos } from '@ground/proto' ;
36
+
37
+ import Pb = GroundProtos . ground . v1beta1 ;
38
+ const l = registry . getFieldIds ( Pb . LocationOfInterest ) ;
39
+ const g = registry . getFieldIds ( Pb . Geometry ) ;
40
+ const p = registry . getFieldIds ( Pb . Point ) ;
41
+ const c = registry . getFieldIds ( Pb . Coordinates ) ;
42
+ const pg = registry . getFieldIds ( Pb . Polygon ) ;
43
+ const lr = registry . getFieldIds ( Pb . LinearRing ) ;
44
+ const mp = registry . getFieldIds ( Pb . MultiPolygon ) ;
49
45
50
46
describe ( 'importGeoJson()' , ( ) => {
51
47
let mockFirestore : Firestore ;
@@ -76,13 +72,13 @@ describe('importGeoJson()', () => {
76
72
] ,
77
73
} ;
78
74
const pointLoi = {
79
- [ $job_id ] : 'job123' ,
80
- [ $ geometry] : {
81
- [ $ point] : { [ $ coordinates] : { [ $ latitude] : 10.1 , [ $ longitude] : 125.6 } } ,
75
+ [ l . jobId ] : 'job123' ,
76
+ [ l . geometry ] : {
77
+ [ g . point ] : { [ p . coordinates ] : { [ c . latitude ] : 10.1 , [ c . longitude ] : 125.6 } } ,
82
78
} ,
83
- [ $submission_count ] : 0 ,
84
- [ $ source] : 1 , // IMPORTED
85
- [ $ properties] : { name : 'Dinagat Islands' , area : 3.08 } ,
79
+ [ l . submissionCount ] : 0 ,
80
+ [ l . source ] : 1 , // IMPORTED
81
+ [ l . properties ] : { name : 'Dinagat Islands' , area : 3.08 } ,
86
82
jobId : 'job123' ,
87
83
predefined : true ,
88
84
geometry : { type : 'Point' , coordinates : TestGeoPoint ( 10.1 , 125.6 ) } ,
@@ -108,21 +104,21 @@ describe('importGeoJson()', () => {
108
104
] ,
109
105
} ;
110
106
const polygonLoi = {
111
- [ $job_id ] : 'job123' ,
112
- [ $ geometry] : {
113
- [ $ polygon] : {
114
- [ $ shell] : {
115
- [ $ coordinates] : [
116
- { [ $ latitude] : 0 , [ $ longitude] : 100 } ,
117
- { [ $ latitude] : 0 , [ $ longitude] : 101 } ,
118
- { [ $ latitude] : 1 , [ $ longitude] : 101 } ,
119
- { [ $ latitude] : 0 , [ $ longitude] : 100 } ,
107
+ [ l . jobId ] : 'job123' ,
108
+ [ l . geometry ] : {
109
+ [ g . polygon ] : {
110
+ [ pg . shell ] : {
111
+ [ lr . coordinates ] : [
112
+ { [ c . latitude ] : 0 , [ c . longitude ] : 100 } ,
113
+ { [ c . latitude ] : 0 , [ c . longitude ] : 101 } ,
114
+ { [ c . latitude ] : 1 , [ c . longitude ] : 101 } ,
115
+ { [ c . latitude ] : 0 , [ c . longitude ] : 100 } ,
120
116
] ,
121
117
} ,
122
118
} ,
123
119
} ,
124
- [ $submission_count ] : 0 ,
125
- [ $ source] : 1 , // IMPORTED
120
+ [ l . submissionCount ] : 0 ,
121
+ [ l . source ] : 1 , // IMPORTED
126
122
jobId : 'job123' ,
127
123
predefined : true ,
128
124
geometry : {
@@ -167,37 +163,37 @@ describe('importGeoJson()', () => {
167
163
] ,
168
164
} ;
169
165
const multiPolygonLoi = {
170
- [ $job_id ] : 'job123' ,
171
- [ $ geometry] : {
172
- [ $multi_polygon ] : {
173
- [ $ polygons] : [
166
+ [ l . jobId ] : 'job123' ,
167
+ [ l . geometry ] : {
168
+ [ g . multiPolygon ] : {
169
+ [ mp . polygons ] : [
174
170
// polygons[0]
175
171
{
176
- [ $ shell] : {
177
- [ $ coordinates] : [
178
- { [ $ latitude] : 0 , [ $ longitude] : 100 } ,
179
- { [ $ latitude] : 0 , [ $ longitude] : 101 } ,
180
- { [ $ latitude] : 1 , [ $ longitude] : 101 } ,
181
- { [ $ latitude] : 0 , [ $ longitude] : 100 } ,
172
+ [ pg . shell ] : {
173
+ [ lr . coordinates ] : [
174
+ { [ c . latitude ] : 0 , [ c . longitude ] : 100 } ,
175
+ { [ c . latitude ] : 0 , [ c . longitude ] : 101 } ,
176
+ { [ c . latitude ] : 1 , [ c . longitude ] : 101 } ,
177
+ { [ c . latitude ] : 0 , [ c . longitude ] : 100 } ,
182
178
] ,
183
179
} ,
184
180
} ,
185
181
// polygons[1]
186
182
{
187
- [ $ shell] : {
188
- [ $ coordinates] : [
189
- { [ $ latitude] : 1 , [ $ longitude] : 120 } ,
190
- { [ $ latitude] : 1 , [ $ longitude] : 121 } ,
191
- { [ $ latitude] : 2 , [ $ longitude] : 121 } ,
192
- { [ $ latitude] : 1 , [ $ longitude] : 120 } ,
183
+ [ pg . shell ] : {
184
+ [ lr . coordinates ] : [
185
+ { [ c . latitude ] : 1 , [ c . longitude ] : 120 } ,
186
+ { [ c . latitude ] : 1 , [ c . longitude ] : 121 } ,
187
+ { [ c . latitude ] : 2 , [ c . longitude ] : 121 } ,
188
+ { [ c . latitude ] : 1 , [ c . longitude ] : 120 } ,
193
189
] ,
194
190
} ,
195
191
} ,
196
192
] ,
197
193
} ,
198
194
} ,
199
- [ $submission_count ] : 0 ,
200
- [ $ source] : 1 , // IMPORTED
195
+ [ l . submissionCount ] : 0 ,
196
+ [ l . source ] : 1 , // IMPORTED
201
197
jobId : 'job123' ,
202
198
predefined : true ,
203
199
geometry : {
0 commit comments