2
2
3
3
import lombok .NonNull ;
4
4
import lombok .SneakyThrows ;
5
+ import net .buildtheearth .terraplusplus .util .compat .sis .SISHelper ;
5
6
import net .daporkchop .lib .common .reference .ReferenceStrength ;
6
7
import net .daporkchop .lib .common .reference .cache .Cached ;
8
+ import org .apache .sis .internal .referencing .ReferencingFactoryContainer ;
7
9
import org .apache .sis .io .wkt .Convention ;
8
10
import org .apache .sis .io .wkt .KeywordCase ;
9
11
import org .apache .sis .io .wkt .KeywordStyle ;
10
12
import org .apache .sis .io .wkt .Symbols ;
11
13
import org .apache .sis .io .wkt .WKTFormat ;
14
+ import org .opengis .referencing .crs .CRSFactory ;
15
+ import org .opengis .referencing .cs .CSFactory ;
16
+ import org .opengis .referencing .datum .DatumFactory ;
17
+ import org .opengis .referencing .operation .CoordinateOperationFactory ;
18
+ import org .opengis .referencing .operation .MathTransformFactory ;
12
19
13
20
import java .text .ParseException ;
14
21
import java .util .Locale ;
@@ -26,18 +33,33 @@ public enum WKTStandard {
26
33
27
34
static {
28
35
{
29
- WKTFormat format = new WKTFormat (Locale .ROOT , TimeZone .getDefault ());
30
- format .setKeywordCase (KeywordCase .UPPER_CASE );
31
- format .setKeywordStyle (KeywordStyle .SHORT );
32
- format .setConvention (Convention .WKT2 );
33
- format .setSymbols (Symbols .SQUARE_BRACKETS );
34
- format .setIndentation (WKTFormat .SINGLE_LINE );
35
- WKT2_2015 .format = Cached . threadLocal ( format :: clone , ReferenceStrength . SOFT );
36
+ WKTFormat baseFormat = new WKTFormat (Locale .ROOT , TimeZone .getDefault ());
37
+ baseFormat .setKeywordCase (KeywordCase .UPPER_CASE );
38
+ baseFormat .setKeywordStyle (KeywordStyle .SHORT );
39
+ baseFormat .setConvention (Convention .WKT2 );
40
+ baseFormat .setSymbols (Symbols .SQUARE_BRACKETS );
41
+ baseFormat .setIndentation (WKTFormat .SINGLE_LINE );
42
+ WKT2_2015 .setFormat ( baseFormat );
36
43
}
37
44
}
38
45
39
46
private Cached <WKTFormat > format ;
40
47
48
+ private void setFormat (@ NonNull WKTFormat baseFormat ) {
49
+ this .format = Cached .threadLocal (() -> {
50
+ ReferencingFactoryContainer factories = SISHelper .factories ();
51
+
52
+ //clone the base WKTFormat instance, and configure it to use the thread-local factory instances from SISHelper.factories()
53
+ WKTFormat format = baseFormat .clone ();
54
+ format .setFactory (CRSFactory .class , factories .getCRSFactory ());
55
+ format .setFactory (CSFactory .class , factories .getCSFactory ());
56
+ format .setFactory (DatumFactory .class , factories .getDatumFactory ());
57
+ format .setFactory (MathTransformFactory .class , factories .getMathTransformFactory ());
58
+ format .setFactory (CoordinateOperationFactory .class , factories .getCoordinateOperationFactory ());
59
+ return format ;
60
+ }, ReferenceStrength .SOFT );
61
+ }
62
+
41
63
public Object parse (@ NonNull String wkt ) throws ParseException {
42
64
return this .format .get ().parseObject (wkt );
43
65
}
0 commit comments