Main.debug("Initializing map style " + source.url + " completed in " + Utils.getDurationString(elapsedTime));
}
}
private static StyleSource fromSourceEntry(SourceEntry entry) {
CachedFile cf = null;
try {
Set<String> mimes = new HashSet<>();
mimes.addAll(Arrays.asList(XmlStyleSource.XML_STYLE_MIME_TYPES.split(", ")));
mimes.addAll(Arrays.asList(MapCSSStyleSource.MAPCSS_STYLE_MIME_TYPES.split(", ")));
cf = new CachedFile(entry.url).setHttpAccept(Utils.join(", ", mimes));
String zipEntryPath = cf.findZipEntryPath("mapcss", "style");
if (zipEntryPath != null) {
entry.isZip = true;
entry.zipEntryPath = zipEntryPath;
return new MapCSSStyleSource(entry);
}
zipEntryPath = cf.findZipEntryPath("xml", "style");
if (zipEntryPath != null)
return new XmlStyleSource(entry);
if (entry.url.toLowerCase().endsWith(".mapcss"))
return new MapCSSStyleSource(entry);
if (entry.url.toLowerCase().endsWith(".xml"))
return new XmlStyleSource(entry);
else {
try (InputStreamReader reader = new InputStreamReader(cf.getInputStream(), StandardCharsets.UTF_8)) {
WHILE: while (true) {
int c = reader.read();
switch (c) {
case -1:
break WHILE;