1 /***********************************************************************
2  * Copyright (c) 2013-2024 Commonwealth Computer Research, Inc.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Apache License, Version 2.0
5  * which accompanies this distribution and is available at
6  * http://www.opensource.org/licenses/apache2.0.php.
7  ***********************************************************************/
8 
9 package org.locationtech.geomesa.utils
10 
11 import org.geotools.api.data.FeatureReader
12 import org.geotools.api.feature.simple.{SimpleFeature, SimpleFeatureType}
13 import org.geotools.api.referencing.crs.CoordinateReferenceSystem
14 import org.geotools.data.collection.DelegateFeatureReader
15 import org.geotools.feature.collection.DelegateFeatureIterator
16 import org.geotools.geometry.jts.ReferencedEnvelope
17 import org.geotools.referencing.CRS
18 import org.geotools.referencing.crs.DefaultGeographicCRS
19 import org.locationtech.geomesa.utils.text.WKTUtils
20 import org.locationtech.jts.geom.{Geometry, Polygon}
21 
22 import java.time.ZoneOffset
23 import java.time.format.DateTimeFormatter
24 
25 package object geotools {
26 
27   // use the epsg jar if it's available (e.g. in geoserver), otherwise use the less-rich constant
28   val CRS_EPSG_4326: CoordinateReferenceSystem =
29     try { CRS.decode("EPSG:4326", true) } catch { case _: Throwable => DefaultGeographicCRS.WGS84 }
30 
31   val CrsEpsg4326: CoordinateReferenceSystem = CRS_EPSG_4326
32 
33   // we make this a function, as envelopes are mutable
34   def wholeWorldEnvelope = new ReferencedEnvelope(-180, 180, -90, 90, CRS_EPSG_4326)
35   val WholeWorldPolygon: Polygon =
36     WKTUtils.read("POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))").asInstanceOf[Polygon]
37   val EmptyGeometry: Geometry = WKTUtils.read("POLYGON EMPTY")
38 
39   // date format with geotools pattern
40   val GeoToolsDateFormat: DateTimeFormatter =
41     DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").withZone(ZoneOffset.UTC)
42 
43   type FR = FeatureReader[SimpleFeatureType, SimpleFeature]
44   type DFR = DelegateFeatureReader[SimpleFeatureType, SimpleFeature]
45   type DFI = DelegateFeatureIterator[SimpleFeature]
46 }
Line Stmt Id Pos Tree Symbol Tests Code
29 9031 1315 - 1344 Apply org.geotools.referencing.CRS.decode org.geotools.referencing.CRS.decode("EPSG:4326", true)
29 9032 1315 - 1344 Block org.geotools.referencing.CRS.decode org.geotools.referencing.CRS.decode("EPSG:4326", true)
29 9033 1376 - 1402 Select org.geotools.referencing.crs.DefaultGeographicCRS.WGS84 org.geotools.referencing.crs.DefaultGeographicCRS.WGS84
29 9034 1376 - 1402 Block org.geotools.referencing.crs.DefaultGeographicCRS.WGS84 org.geotools.referencing.crs.DefaultGeographicCRS.WGS84
31 9035 1453 - 1466 Select org.locationtech.geomesa.utils.geotools.CRS_EPSG_4326 `package`.this.CRS_EPSG_4326
34 9036 1573 - 1577 Literal <nosymbol> -180.0
34 9037 1579 - 1582 Literal <nosymbol> 180.0
34 9038 1584 - 1587 Literal <nosymbol> -90.0
34 9039 1589 - 1591 Literal <nosymbol> 90.0
34 9040 1593 - 1606 Select org.locationtech.geomesa.utils.geotools.CRS_EPSG_4326 `package`.this.CRS_EPSG_4326
34 9041 1550 - 1607 Apply org.geotools.geometry.jts.ReferencedEnvelope.<init> new org.geotools.geometry.jts.ReferencedEnvelope(-180.0, 180.0, -90.0, 90.0, `package`.this.CRS_EPSG_4326)
36 9042 1661 - 1718 Literal <nosymbol> "POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))"
36 9043 1647 - 1741 TypeApply scala.Any.asInstanceOf org.locationtech.geomesa.utils.text.WKTUtils.read("POLYGON((-180 -90, 180 -90, 180 90, -180 90, -180 -90))").asInstanceOf[org.locationtech.jts.geom.Polygon]
37 9044 1774 - 1804 Apply org.locationtech.geomesa.utils.text.WKTUtils.read org.locationtech.geomesa.utils.text.WKTUtils.read("POLYGON EMPTY")
41 9045 1923 - 1953 Literal <nosymbol> "yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'"
41 9046 1964 - 1978 Select java.time.ZoneOffset.UTC java.time.ZoneOffset.UTC
41 9047 1895 - 1979 Apply java.time.format.DateTimeFormatter.withZone java.time.format.DateTimeFormatter.ofPattern("yyyy-MM-dd\'T\'HH:mm:ss.SSS\'Z\'").withZone(java.time.ZoneOffset.UTC)