surrealdb_core/syn/parser/
object.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
use std::collections::BTreeMap;

use reblessive::Stk;

use crate::{
	sql::{Block, Geometry, Object, Strand, Value},
	syn::{
		error::bail,
		lexer::compound,
		parser::{enter_object_recursion, mac::expected, ParseResult, Parser},
		token::{t, Glued, Span, TokenKind},
	},
};

use super::mac::unexpected;

impl Parser<'_> {
	/// Parse an production which starts with an `{`
	///
	/// Either a block statemnt, a object or geometry.
	pub(super) async fn parse_object_like(
		&mut self,
		ctx: &mut Stk,
		start: Span,
	) -> ParseResult<Value> {
		if self.eat(t!("}")) {
			// empty object, just return
			enter_object_recursion!(_this = self => {
				return Ok(Value::Object(Object::default()));
			})
		}

		// Now check first if it can be an object.
		if self.glue_and_peek1()?.kind == t!(":") {
			enter_object_recursion!(this = self => {
			   return this.parse_object_or_geometry(ctx, start).await;
			})
		}

		// not an object so instead parse as a block.
		self.parse_block(ctx, start).await.map(Box::new).map(Value::Block)
	}

	async fn parse_object_or_geometry_after_type(
		&mut self,
		ctx: &mut Stk,
		start: Span,
		key: String,
	) -> ParseResult<Value> {
		expected!(self, t!(":"));
		// for it to be geometry the next value must be a strand like.
		let (t!("\"") | t!("'") | TokenKind::Glued(Glued::Strand)) = self.peek_kind() else {
			return self
				.parse_object_from_key(ctx, key, BTreeMap::new(), start)
				.await
				.map(Value::Object);
		};

		// We know it is a strand so check if the type is one of the allowe geometry types.
		// If it is, there are some which all take roughly the save type of value and produce a
		// similar output, which is parsed with parse_geometry_after_type
		//
		// GeometryCollection however has a different object key for its value, so it is handled
		// appart from the others.
		let type_value = self.next_token_value::<Strand>()?.0;
		match type_value.as_str() {
			"Point" => {
				// we matched a type correctly but the field containing the geometry value
				// can still be wrong.
				//
				// we can unwrap strand since we just matched it to not be an err.
				self.parse_geometry_after_type(
					ctx,
					start,
					key,
					type_value,
					Geometry::array_to_point,
					|x| Value::Geometry(Geometry::Point(x)),
				)
				.await
			}
			"LineString" => {
				self.parse_geometry_after_type(
					ctx,
					start,
					key,
					type_value,
					Geometry::array_to_line,
					|x| Value::Geometry(Geometry::Line(x)),
				)
				.await
			}
			"Polygon" => {
				self.parse_geometry_after_type(
					ctx,
					start,
					key,
					type_value,
					Geometry::array_to_polygon,
					|x| Value::Geometry(Geometry::Polygon(x)),
				)
				.await
			}
			"MultiPoint" => {
				self.parse_geometry_after_type(
					ctx,
					start,
					key,
					type_value,
					Geometry::array_to_multipoint,
					|x| Value::Geometry(Geometry::MultiPoint(x)),
				)
				.await
			}
			"MultiLineString" => {
				self.parse_geometry_after_type(
					ctx,
					start,
					key,
					type_value,
					Geometry::array_to_multiline,
					|x| Value::Geometry(Geometry::MultiLine(x)),
				)
				.await
			}
			"MultiPolygon" => {
				self.parse_geometry_after_type(
					ctx,
					start,
					key,
					type_value,
					Geometry::array_to_multipolygon,
					|x| Value::Geometry(Geometry::MultiPolygon(x)),
				)
				.await
			}
			"GeometryCollection" => {
				if !self.eat(t!(",")) {
					// missing next field, not a geometry.
					return self
						.parse_object_from_map(
							ctx,
							BTreeMap::from([(key, Value::Strand(type_value.into()))]),
							start,
						)
						.await
						.map(Value::Object);
				}

				let coord_key = self.parse_object_key()?;
				if coord_key != "geometries" {
					expected!(self, t!(":"));
					// invalid field key, not a Geometry
					return self
						.parse_object_from_key(
							ctx,
							coord_key,
							BTreeMap::from([(key, Value::Strand(type_value.into()))]),
							start,
						)
						.await
						.map(Value::Object);
				}

				expected!(self, t!(":"));

				let value = ctx.run(|ctx| self.parse_value_inherit(ctx)).await?;

				// check for an object end, if it doesn't end it is not a geometry.
				if !self.eat(t!(",")) {
					self.expect_closing_delimiter(t!("}"), start)?;
				} else {
					if self.peek_kind() != t!("}") {
						// A comma and then no brace. more then two fields, not a geometry.
						return self
							.parse_object_from_map(
								ctx,
								BTreeMap::from([
									(key, Value::Strand(type_value.into())),
									(coord_key, value),
								]),
								start,
							)
							.await
							.map(Value::Object);
					}
					self.pop_peek();
				}

				// try to convert to the right value.
				if let Value::Array(x) = value {
					// test first to avoid a cloning.
					if x.iter().all(|x| matches!(x, Value::Geometry(_))) {
						let geometries =
							x.0.into_iter()
								.map(|x| {
									if let Value::Geometry(x) = x {
										x
									} else {
										unreachable!()
									}
								})
								.collect();

						return Ok(Value::Geometry(Geometry::Collection(geometries)));
					}

					return Ok(Value::Object(Object(BTreeMap::from([
						(key, Value::Strand(type_value.into())),
						(coord_key, Value::Array(x)),
					]))));
				}

				// Couldn't convert so it is a normal object.
				Ok(Value::Object(Object(BTreeMap::from([
					(key, Value::Strand(type_value.into())),
					(coord_key, value),
				]))))
			}
			// key was not one of the allowed keys so it is a normal object.
			_ => {
				let object = BTreeMap::from([(key, Value::Strand(type_value.into()))]);

				if self.eat(t!(",")) {
					self.parse_object_from_map(ctx, object, start).await.map(Value::Object)
				} else {
					self.expect_closing_delimiter(t!("}"), start)?;
					Ok(Value::Object(Object(object)))
				}
			}
		}
	}

	async fn parse_object_or_geometry_after_coordinates(
		&mut self,
		ctx: &mut Stk,
		start: Span,
		key: String,
	) -> ParseResult<Value> {
		expected!(self, t!(":"));

		// found coordinates field, next must be a coordinates value but we don't know
		// which until we match type.
		let value = ctx.run(|ctx| self.parse_value_inherit(ctx)).await?;

		if !self.eat(t!(",")) {
			// no comma object must end early.
			self.expect_closing_delimiter(t!("}"), start)?;
			return Ok(Value::Object(Object(BTreeMap::from([(key, value)]))));
		}

		if self.eat(t!("}")) {
			// object ends early.
			return Ok(Value::Object(Object(BTreeMap::from([(key, value)]))));
		}

		let type_key = self.parse_object_key()?;
		if type_key != "type" {
			expected!(self, t!(":"));
			// not the right field, return object.
			return self
				.parse_object_from_key(ctx, type_key, BTreeMap::from([(key, value)]), start)
				.await
				.map(Value::Object);
		}
		expected!(self, t!(":"));

		let (t!("\"") | t!("'")) = self.peek_kind() else {
			// not the right value also move back to parsing an object.
			return self
				.parse_object_from_key(ctx, type_key, BTreeMap::from([(key, value)]), start)
				.await
				.map(Value::Object);
		};

		let type_value = self.next_token_value::<Strand>()?.0;
		let ate_comma = self.eat(t!(","));
		// match the type and then match the coordinates field to a value of that type.
		match type_value.as_str() {
			"Point" => {
				if self.eat(t!("}")) {
					if let Some(point) = Geometry::array_to_point(&value) {
						return Ok(Value::Geometry(Geometry::Point(point)));
					}
				}
			}
			"LineString" => {
				if self.eat(t!("}")) {
					if let Some(point) = Geometry::array_to_line(&value) {
						return Ok(Value::Geometry(Geometry::Line(point)));
					}
				}
			}
			"Polygon" => {
				if self.eat(t!("}")) {
					if let Some(point) = Geometry::array_to_polygon(&value) {
						return Ok(Value::Geometry(Geometry::Polygon(point)));
					}
				}
			}
			"MultiPoint" => {
				if self.eat(t!("}")) {
					if let Some(point) = Geometry::array_to_multipolygon(&value) {
						return Ok(Value::Geometry(Geometry::MultiPolygon(point)));
					}
				}
			}
			"MultiLineString" => {
				if self.eat(t!("}")) {
					if let Some(point) = Geometry::array_to_multiline(&value) {
						return Ok(Value::Geometry(Geometry::MultiLine(point)));
					}
				}
			}
			"MultiPolygon" => {
				if self.eat(t!("}")) {
					if let Some(point) = Geometry::array_to_multipolygon(&value) {
						return Ok(Value::Geometry(Geometry::MultiPolygon(point)));
					}
				}
			}
			_ => {}
		};

		// type field or coordinates value didn't match or the object continues after to
		// fields.

		if !ate_comma {
			self.expect_closing_delimiter(t!("}"), start)?;
			return Ok(Value::Object(Object(BTreeMap::from([
				(key, value),
				(type_key, Value::Strand(type_value.into())),
			]))));
		}

		self.parse_object_from_map(
			ctx,
			BTreeMap::from([(key, value), (type_key, Value::Strand(type_value.into()))]),
			start,
		)
		.await
		.map(Value::Object)
	}

	async fn parse_object_or_geometry_after_geometries(
		&mut self,
		ctx: &mut Stk,
		start: Span,
		key: String,
	) -> ParseResult<Value> {
		// 'geometries' key can only happen in a GeometryCollection, so try to parse that.
		expected!(self, t!(":"));

		let value = ctx.run(|ctx| self.parse_value_inherit(ctx)).await?;

		// if the object ends here, it is not a geometry.
		if !self.eat(t!(",")) || self.peek_kind() == t!("}") {
			self.expect_closing_delimiter(t!("}"), start)?;
			return Ok(Value::Object(Object(BTreeMap::from([(key, value)]))));
		}

		// parse the next objectkey
		let type_key = self.parse_object_key()?;
		// it if isn't 'type' this object is not a geometry, so bail.
		if type_key != "type" {
			expected!(self, t!(":"));
			return self
				.parse_object_from_key(ctx, type_key, BTreeMap::from([(key, value)]), start)
				.await
				.map(Value::Object);
		}
		expected!(self, t!(":"));
		// check if the next key is a strand.
		let (t!("\"") | t!("'")) = self.peek_kind() else {
			// not the right value also move back to parsing an object.
			return self
				.parse_object_from_key(ctx, type_key, BTreeMap::from([(key, value)]), start)
				.await
				.map(Value::Object);
		};

		let type_value = self.next_token_value::<Strand>()?.0;
		let ate_comma = self.eat(t!(","));

		if type_value == "GeometryCollection" && self.eat(t!("}")) {
			if let Value::Array(ref x) = value {
				if x.iter().all(|x| matches!(x, Value::Geometry(_))) {
					let Value::Array(x) = value else {
						unreachable!()
					};
					let geometries = x
						.into_iter()
						.map(|x| {
							if let Value::Geometry(x) = x {
								x
							} else {
								unreachable!()
							}
						})
						.collect();
					return Ok(Value::Geometry(Geometry::Collection(geometries)));
				}
			}
		}

		// Either type value didn't match or gemoetry value didn't match.
		// Regardless the current object is not a geometry.

		if !ate_comma {
			self.expect_closing_delimiter(t!("}"), start)?;
			return Ok(Value::Object(Object(BTreeMap::from([
				(key, value),
				(type_key, Value::Strand(type_value.into())),
			]))));
		}

		self.parse_object_from_map(
			ctx,
			BTreeMap::from([(key, value), (type_key, Value::Strand(type_value.into()))]),
			start,
		)
		.await
		.map(Value::Object)
	}

	/// Parse a production starting with an `{` as either an object or a geometry.
	///
	/// This function tries to match an object to an geometry like object and if it is unable
	/// fallsback to parsing normal objects.
	async fn parse_object_or_geometry(&mut self, ctx: &mut Stk, start: Span) -> ParseResult<Value> {
		// empty object was already matched previously so next must be a key.
		let key = self.parse_object_key()?;
		// the order of fields of a geometry does not matter so check if it is any of geometry like keys
		// "type" : could be the type of the object.
		// "collections": could be a geometry collection.
		// "geometry": could be the values of geometry.
		match key.as_str() {
			"type" => self.parse_object_or_geometry_after_type(ctx, start, key).await,
			"coordinates" => self.parse_object_or_geometry_after_coordinates(ctx, start, key).await,
			"geometries" => self.parse_object_or_geometry_after_geometries(ctx, start, key).await,
			_ => {
				expected!(self, t!(":"));
				self.parse_object_from_key(ctx, key, BTreeMap::new(), start)
					.await
					.map(Value::Object)
			}
		}
	}

	async fn parse_geometry_after_type<F, Fm, R>(
		&mut self,
		ctx: &mut Stk,
		start: Span,
		key: String,
		strand: String,
		capture: F,
		map: Fm,
	) -> ParseResult<Value>
	where
		F: FnOnce(&Value) -> Option<R>,
		Fm: FnOnce(R) -> Value,
	{
		if !self.eat(t!(",")) {
			// there is not second field. not a geometry
			self.expect_closing_delimiter(t!("}"), start)?;
			return Ok(Value::Object(Object(BTreeMap::from([(
				key,
				Value::Strand(strand.into()),
			)]))));
		}
		let coord_key = self.parse_object_key()?;
		if coord_key != "coordinates" {
			expected!(self, t!(":"));
			// next field was not correct, fallback to parsing plain object.
			return self
				.parse_object_from_key(
					ctx,
					coord_key,
					BTreeMap::from([(key, Value::Strand(strand.into()))]),
					start,
				)
				.await
				.map(Value::Object);
		}
		expected!(self, t!(":"));
		let value = ctx.run(|ctx| self.parse_value_inherit(ctx)).await?;
		let comma = self.eat(t!(","));
		if !self.eat(t!("}")) {
			// the object didn't end, either an error or not a geometry.
			if !comma {
				bail!("Unexpected token, expected delimiter `}}`",
					@self.recent_span(),
					@start => "expected this delimiter to close"
				);
			}

			return self
				.parse_object_from_map(
					ctx,
					BTreeMap::from([(key, Value::Strand(strand.into())), (coord_key, value)]),
					start,
				)
				.await
				.map(Value::Object);
		}

		let Some(v) = capture(&value) else {
			// failed to match the geometry value, just a plain object.
			return Ok(Value::Object(Object(BTreeMap::from([
				(key, Value::Strand(strand.into())),
				(coord_key, value),
			]))));
		};
		// successfully matched the value, it is a geometry.
		Ok(map(v))
	}

	async fn parse_object_from_key(
		&mut self,
		ctx: &mut Stk,
		key: String,
		mut map: BTreeMap<String, Value>,
		start: Span,
	) -> ParseResult<Object> {
		let v = ctx.run(|ctx| self.parse_value_inherit(ctx)).await?;
		map.insert(key, v);
		if !self.eat(t!(",")) {
			self.expect_closing_delimiter(t!("}"), start)?;
			return Ok(Object(map));
		}
		self.parse_object_from_map(ctx, map, start).await
	}

	/// Parses an object.
	///
	/// Expects the span of the starting `{` as an argument.
	///
	/// # Parser state
	/// Expects the first `{` to already have been eaten.
	pub(super) async fn parse_object(&mut self, ctx: &mut Stk, start: Span) -> ParseResult<Object> {
		enter_object_recursion!(this = self => {
			this.parse_object_from_map(ctx, BTreeMap::new(), start).await
		})
	}

	async fn parse_object_from_map(
		&mut self,
		ctx: &mut Stk,
		mut map: BTreeMap<String, Value>,
		start: Span,
	) -> ParseResult<Object> {
		loop {
			if self.eat(t!("}")) {
				return Ok(Object(map));
			}

			let (key, value) = self.parse_object_entry(ctx).await?;
			// TODO: Error on duplicate key?
			map.insert(key, value);

			if !self.eat(t!(",")) {
				self.expect_closing_delimiter(t!("}"), start)?;
				return Ok(Object(map));
			}
		}
	}

	/// Parses a block of statements
	///
	/// # Parser State
	/// Expects the starting `{` to have already been eaten and its span to be handed to this
	/// functions as the `start` parameter.
	pub async fn parse_block(&mut self, ctx: &mut Stk, start: Span) -> ParseResult<Block> {
		let mut statements = Vec::new();
		loop {
			while self.eat(t!(";")) {}
			if self.eat(t!("}")) {
				break;
			}

			let stmt = ctx.run(|ctx| self.parse_entry(ctx)).await?;
			statements.push(stmt);
			if !self.eat(t!(";")) {
				self.expect_closing_delimiter(t!("}"), start)?;
				break;
			}
		}
		Ok(Block(statements))
	}

	/// Parse a single entry in the object, i.e. `field: value + 1` in the object `{ field: value +
	/// 1 }`
	async fn parse_object_entry(&mut self, ctx: &mut Stk) -> ParseResult<(String, Value)> {
		let text = self.parse_object_key()?;
		expected!(self, t!(":"));
		let value = ctx.run(|ctx| self.parse_value_inherit(ctx)).await?;
		Ok((text, value))
	}

	/// Parses the key of an object, i.e. `field` in the object `{ field: 1 }`.
	pub(super) fn parse_object_key(&mut self) -> ParseResult<String> {
		let token = self.peek();
		match token.kind {
			x if Self::kind_is_keyword_like(x) => {
				self.pop_peek();
				let str = self.lexer.span_str(token.span);
				Ok(str.to_string())
			}
			TokenKind::Identifier => {
				self.pop_peek();
				let str = self.lexer.string.take().unwrap();
				Ok(str)
			}
			t!("\"") | t!("'") | TokenKind::Glued(Glued::Strand) => {
				let str = self.next_token_value::<Strand>()?.0;
				Ok(str)
			}
			TokenKind::Digits => {
				self.pop_peek();
				let span = self.lexer.lex_compound(token, compound::number)?.span;
				let str = self.lexer.span_str(span);
				Ok(str.to_string())
			}
			TokenKind::Glued(Glued::Number) => {
				self.pop_peek();
				let str = self.lexer.span_str(token.span);
				Ok(str.to_string())
			}
			_ => unexpected!(self, token, "an object key"),
		}
	}
}

#[cfg(test)]
mod test {
	use super::*;
	use crate::syn::Parse;

	#[test]
	fn block_value() {
		let sql = "{ 80 }";
		let out = Value::parse(sql);
		assert_eq!(sql, out.to_string())
	}

	#[test]
	fn block_ifelse() {
		let sql = "{ RETURN IF true THEN 50 ELSE 40 END; }";
		let out = Value::parse(sql);
		assert_eq!(sql, out.to_string())
	}

	#[test]
	fn block_multiple() {
		let sql = r#"{

	LET $person = (SELECT * FROM person WHERE first = $first AND last = $last AND birthday = $birthday);

	RETURN IF $person[0].id THEN
		$person[0]
	ELSE
		(CREATE person SET first = $first, last = $last, birthday = $birthday)
	END;

}"#;
		let out = Value::parse(sql);
		assert_eq!(sql, format!("{:#}", out))
	}
}

#[cfg(test)]
mod tests {
	use super::*;
	use crate::syn::Parse;

	#[test]
	fn simple() {
		let sql = "(-0.118092, 51.509865)";
		let out = Value::parse(sql);
		assert!(matches!(out, Value::Geometry(_)));
		assert_eq!("(-0.118092, 51.509865)", format!("{}", out));
	}

	#[test]
	fn point() {
		let sql = r#"{
			type: 'Point',
			coordinates: [-0.118092, 51.509865]
		}"#;
		let out = Value::parse(sql);
		assert!(matches!(out, Value::Geometry(_)));
		assert_eq!("(-0.118092, 51.509865)", format!("{}", out));
	}

	#[test]
	fn polygon_exterior() {
		let sql = r#"{
			type: 'Polygon',
			coordinates: [
				[
					[-0.38314819, 51.37692386], [0.1785278, 51.37692386],
					[0.1785278, 51.61460570], [-0.38314819, 51.61460570],
					[-0.38314819, 51.37692386]
				]
			]
		}"#;
		let out = Value::parse(sql);
		assert!(matches!(out, Value::Geometry(_)));
		assert_eq!("{ type: 'Polygon', coordinates: [[[-0.38314819, 51.37692386], [0.1785278, 51.37692386], [0.1785278, 51.6146057], [-0.38314819, 51.6146057], [-0.38314819, 51.37692386]]] }", format!("{}", out));
	}

	#[test]
	fn polygon_interior() {
		let sql = r#"{
			type: 'Polygon',
			coordinates: [
				[
					[-0.38314819, 51.37692386], [0.1785278, 51.37692386],
					[0.1785278, 51.61460570], [-0.38314819, 51.61460570],
					[-0.38314819, 51.37692386]
				],
				[
					[-0.38314819, 51.37692386], [0.1785278, 51.37692386],
					[0.1785278, 51.61460570], [-0.38314819, 51.61460570],
					[-0.38314819, 51.37692386]
				]
			]
		}"#;
		let out = Value::parse(sql);
		assert!(matches!(out, Value::Geometry(_)));
		assert_eq!("{ type: 'Polygon', coordinates: [[[-0.38314819, 51.37692386], [0.1785278, 51.37692386], [0.1785278, 51.6146057], [-0.38314819, 51.6146057], [-0.38314819, 51.37692386]], [[-0.38314819, 51.37692386], [0.1785278, 51.37692386], [0.1785278, 51.6146057], [-0.38314819, 51.6146057], [-0.38314819, 51.37692386]]] }", format!("{}", out));
	}
}