@@ -108,6 +108,8 @@ public class TileLayerSource implements Serializable {
108
108
public static final String LAYER_NOOVERLAY = "NOOVERLAY" ;
109
109
public static final String LAYER_BING = "BING" ;
110
110
111
+ private static final String SWITCH_START = "{switch:" ;
112
+
111
113
private static final String WMS_VERSION_130 = "1.3.0" ;
112
114
113
115
public enum TileType {
@@ -616,6 +618,19 @@ public TileLayerSource(@NonNull final Context ctx, @Nullable final String id, @N
616
618
readOnly = true ;
617
619
}
618
620
621
+ // extract switch values
622
+ // this needs to happen before URL parsing, as the ":" will trip things up
623
+ int switchPos = tileUrl .indexOf (SWITCH_START );
624
+ if (switchPos >= 0 ) {
625
+ int switchEnd = tileUrl .indexOf ('}' , switchPos );
626
+ if (switchEnd >= 0 ) {
627
+ String switchValues = tileUrl .substring (switchPos + SWITCH_START .length (), switchEnd );
628
+ Collections .addAll (getSubdomains (), switchValues .split ("," ));
629
+ StringBuilder t = new StringBuilder (tileUrl );
630
+ setTileUrl (t .replace (switchPos , switchEnd + 1 , "{subdomain}" ).toString ());
631
+ }
632
+ }
633
+
619
634
String urlPath = null ;
620
635
try {
621
636
URL parsedUrl = new URL (tileUrl );
@@ -675,19 +690,6 @@ protected Void doInBackground(String... params) {
675
690
setImageExtension (FileExtensions .JPG );
676
691
return ;
677
692
}
678
-
679
- // extract switch values
680
- final String SWITCH_START = "{switch:" ;
681
- int switchPos = tileUrl .indexOf (SWITCH_START );
682
- if (switchPos >= 0 ) {
683
- int switchEnd = tileUrl .indexOf ('}' , switchPos );
684
- if (switchEnd >= 0 ) {
685
- String switchValues = tileUrl .substring (switchPos + SWITCH_START .length (), switchEnd );
686
- Collections .addAll (getSubdomains (), switchValues .split ("," ));
687
- StringBuilder t = new StringBuilder (tileUrl );
688
- setTileUrl (t .replace (switchPos , switchEnd + 1 , "{subdomain}" ).toString ());
689
- }
690
- }
691
693
}
692
694
693
695
/**
0 commit comments