gwt: use shader assets
- add some url options for 'map' and 'theme' - use local asset folder - merge assets in local directory
This commit is contained in:
parent
1b211df73e
commit
c6f44e7bbf
1
.gitignore
vendored
1
.gitignore
vendored
@ -16,6 +16,7 @@ build/
|
|||||||
/vtm-android-example/assets/
|
/vtm-android-example/assets/
|
||||||
/vtm-gdx-desktop/assets/
|
/vtm-gdx-desktop/assets/
|
||||||
/vtm-gdx-html/war/
|
/vtm-gdx-html/war/
|
||||||
|
/vtm-gdx-html/assets/
|
||||||
/vtm-gdx-html/gwt-unitCache
|
/vtm-gdx-html/gwt-unitCache
|
||||||
/vtm-spatialite/
|
/vtm-spatialite/
|
||||||
/vtm-spatialite-android/
|
/vtm-spatialite-android/
|
||||||
|
@ -43,7 +43,12 @@ gwt {
|
|||||||
superDev {
|
superDev {
|
||||||
noPrecompile=true
|
noPrecompile=true
|
||||||
}
|
}
|
||||||
|
compiler {
|
||||||
|
enableClosureCompiler = false; // activates -XenableClosureCompiler
|
||||||
|
disableClassMetadata = true; // activates -XdisableClassMetadata
|
||||||
|
disableCastChecking = true; // activates -XdisableCastChecking
|
||||||
|
}
|
||||||
|
|
||||||
src += files(sourceSets.main.java.srcDirs)
|
src += files(sourceSets.main.java.srcDirs)
|
||||||
src += files(project(':vtm').sourceSets.main.allJava.srcDirs)
|
src += files(project(':vtm').sourceSets.main.allJava.srcDirs)
|
||||||
src += files(project(':vtm-themes').sourceSets.main.allJava.srcDirs)
|
src += files(project(':vtm-themes').sourceSets.main.allJava.srcDirs)
|
||||||
@ -58,6 +63,23 @@ task jettyDraftWar(type: JettyRunWar) {
|
|||||||
webApp=draftWar.archivePath
|
webApp=draftWar.archivePath
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task copyThemeAssets(type: Copy) {
|
||||||
|
from "$rootDir/vtm-themes/resources/assets"
|
||||||
|
into "assets"
|
||||||
|
include '**/*'
|
||||||
|
}
|
||||||
|
|
||||||
|
task copyVtmAssets(type: Copy) {
|
||||||
|
from "$rootDir/vtm/resources/assets"
|
||||||
|
into "assets"
|
||||||
|
include '**/*'
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile) { compileTask ->
|
||||||
|
compileTask.dependsOn copyThemeAssets
|
||||||
|
compileTask.dependsOn copyVtmAssets
|
||||||
|
}
|
||||||
|
|
||||||
// Configuring Eclipse classpath
|
// Configuring Eclipse classpath
|
||||||
eclipse.classpath {
|
eclipse.classpath {
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
<super-source path="emu" />
|
<super-source path="emu" />
|
||||||
|
|
||||||
<set-configuration-property name="gdx.assetpath" value="../vtm-themes/resources/assets" />
|
<set-configuration-property name="gdx.assetpath" value="./assets" />
|
||||||
<!-- for gradle build, commend out for eclipse build/devmode -->
|
<!-- for gradle build, commend out for eclipse build/devmode -->
|
||||||
<set-configuration-property name="gdx.assetoutputpath" value="build/gwt/draftOut" />
|
<set-configuration-property name="gdx.assetoutputpath" value="build/gwt/draftOut" />
|
||||||
|
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.gdx.client;
|
package org.oscim.gdx.client;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
import org.oscim.backend.CanvasAdapter;
|
import org.oscim.backend.CanvasAdapter;
|
||||||
import org.oscim.backend.GL20;
|
import org.oscim.backend.GL20;
|
||||||
import org.oscim.backend.GLAdapter;
|
import org.oscim.backend.GLAdapter;
|
||||||
@ -23,9 +25,14 @@ import org.oscim.core.MapPosition;
|
|||||||
import org.oscim.core.MercatorProjection;
|
import org.oscim.core.MercatorProjection;
|
||||||
import org.oscim.gdx.GdxMap;
|
import org.oscim.gdx.GdxMap;
|
||||||
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
|
||||||
|
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||||
|
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||||
import org.oscim.renderer.MapRenderer;
|
import org.oscim.renderer.MapRenderer;
|
||||||
|
import org.oscim.theme.VtmThemes;
|
||||||
import org.oscim.tiling.TileSource;
|
import org.oscim.tiling.TileSource;
|
||||||
import org.oscim.tiling.source.bitmap.DefaultSources.NaturalEarth;
|
import org.oscim.tiling.source.bitmap.BitmapTileSource;
|
||||||
|
import org.oscim.tiling.source.bitmap.DefaultSources;
|
||||||
|
import org.oscim.tiling.source.bitmap.DefaultSources.StamenToner;
|
||||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -66,14 +73,20 @@ class GwtGdxMap extends GdxMap {
|
|||||||
|
|
||||||
float tilt = 0;
|
float tilt = 0;
|
||||||
float rotation = 0;
|
float rotation = 0;
|
||||||
|
String themeName = null;
|
||||||
|
String mapName = null;
|
||||||
|
|
||||||
|
final HashMap<String, String> params = new HashMap<String, String>();
|
||||||
|
String addOpts = "";
|
||||||
if (Window.Location.getHash() != null) {
|
if (Window.Location.getHash() != null) {
|
||||||
String hash = Window.Location.getHash();
|
String hash = Window.Location.getHash();
|
||||||
|
|
||||||
hash = hash.substring(1);
|
hash = hash.substring(1);
|
||||||
String[] pairs = hash.split(",");
|
String[] urlParams = null;
|
||||||
|
urlParams = hash.split("&");
|
||||||
|
if (urlParams.length == 1)
|
||||||
|
urlParams = hash.split(",");
|
||||||
|
|
||||||
for (String p : pairs) {
|
for (String p : urlParams) {
|
||||||
try {
|
try {
|
||||||
if (p.startsWith("lat="))
|
if (p.startsWith("lat="))
|
||||||
lat = Double.parseDouble(p.substring(4));
|
lat = Double.parseDouble(p.substring(4));
|
||||||
@ -85,33 +98,82 @@ class GwtGdxMap extends GdxMap {
|
|||||||
rotation = Float.parseFloat(p.substring(4));
|
rotation = Float.parseFloat(p.substring(4));
|
||||||
else if (p.startsWith("tilt="))
|
else if (p.startsWith("tilt="))
|
||||||
tilt = Float.parseFloat(p.substring(5));
|
tilt = Float.parseFloat(p.substring(5));
|
||||||
|
else if (p.startsWith("theme="))
|
||||||
|
themeName = p.substring(6);
|
||||||
|
else if (p.startsWith("map="))
|
||||||
|
mapName = p.substring(4);
|
||||||
|
else {
|
||||||
|
String[] opt = p.split("=");
|
||||||
|
if (opt.length > 1)
|
||||||
|
params.put(opt[0], opt[1]);
|
||||||
|
else
|
||||||
|
params.put(opt[0], null);
|
||||||
|
|
||||||
|
addOpts += p + "&";
|
||||||
|
|
||||||
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final String addParam =
|
||||||
|
(themeName == null ? "" : ("theme=" + themeName + "&"))
|
||||||
|
+ (mapName == null ? "" : ("map=" + mapName + "&"))
|
||||||
|
+ addOpts;
|
||||||
|
|
||||||
MapPosition p = new MapPosition();
|
MapPosition p = new MapPosition();
|
||||||
p.setZoomLevel(zoom);
|
p.setZoomLevel(zoom);
|
||||||
p.setPosition(lat, lon);
|
p.setPosition(lat, lon);
|
||||||
log.debug("map position: " + p.x + "/" + p.y + " " + lat + "/" + lon);
|
|
||||||
|
|
||||||
p.bearing = rotation;
|
p.bearing = rotation;
|
||||||
p.tilt = tilt;
|
p.tilt = tilt;
|
||||||
|
|
||||||
mMap.setMapPosition(p);
|
mMap.setMapPosition(p);
|
||||||
|
|
||||||
//mMap.getViewport().setTilt(tilt);
|
VectorTileLayer l = null;
|
||||||
//mMap.getViewport().setRotation(rotation);
|
|
||||||
|
|
||||||
String url = c.getTileUrl();
|
if (c.getBackgroundLayer() != null || mapName != null) {
|
||||||
String sourceName = c.getTileSource();
|
BitmapTileSource ts;
|
||||||
|
|
||||||
TileSource tileSource;
|
if ("toner".equals(mapName))
|
||||||
tileSource = new OSciMap4TileSource(url);
|
ts = new StamenToner();
|
||||||
|
else if ("osm".equals(mapName))
|
||||||
|
ts = new DefaultSources.OpenStreetMap();
|
||||||
|
else if ("watercolor".equals(mapName))
|
||||||
|
ts = new DefaultSources.StamenWatercolor();
|
||||||
|
else if ("arcgis-shaded".equals(mapName))
|
||||||
|
ts = new DefaultSources.ArcGISWorldShaded();
|
||||||
|
else if ("imagico".equals(mapName))
|
||||||
|
ts = new DefaultSources.ImagicoLandcover();
|
||||||
|
else
|
||||||
|
ts = new StamenToner();
|
||||||
|
|
||||||
initDefaultLayers(tileSource, false, true, true);
|
mMap.setBackgroundMap(new BitmapTileLayer(mMap, ts));
|
||||||
|
} else {
|
||||||
|
String url = c.getTileUrl();
|
||||||
|
|
||||||
if ("naturalearth".equals(c.getBackgroundLayer()))
|
TileSource ts = new OSciMap4TileSource(url);
|
||||||
mMap.setBackgroundMap(new BitmapTileLayer(mMap, new NaturalEarth()));
|
l = mMap.setBaseMap(ts);
|
||||||
|
|
||||||
|
if (themeName == null) {
|
||||||
|
mMap.setTheme(VtmThemes.DEFAULT);
|
||||||
|
} else {
|
||||||
|
if ("osmarender".equals(themeName))
|
||||||
|
mMap.setTheme(VtmThemes.OSMARENDER);
|
||||||
|
else if ("tron".equals(themeName))
|
||||||
|
mMap.setTheme(VtmThemes.TRONRENDER);
|
||||||
|
else if ("newtron".equals(themeName))
|
||||||
|
mMap.setTheme(VtmThemes.NEWTRON);
|
||||||
|
else
|
||||||
|
mMap.setTheme(VtmThemes.DEFAULT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (l != null) {
|
||||||
|
if (!params.containsKey("nolabel"))
|
||||||
|
mMap.layers().add(new LabelLayer(mMap, l));
|
||||||
|
}
|
||||||
|
|
||||||
mSearchBox = new SearchBox(mMap);
|
mSearchBox = new SearchBox(mMap);
|
||||||
|
|
||||||
@ -139,9 +201,12 @@ class GwtGdxMap extends GdxMap {
|
|||||||
|
|
||||||
String newURL = Window.Location
|
String newURL = Window.Location
|
||||||
.createUrlBuilder()
|
.createUrlBuilder()
|
||||||
.setHash("scale=" + pos.zoomLevel + ",rot=" + curRot
|
.setHash(addParam
|
||||||
+ ",tilt=" + curTilt + ",lat=" + (curLat / 1000f)
|
+ "scale=" + pos.zoomLevel
|
||||||
+ ",lon=" + (curLon / 1000f))
|
+ "&rot=" + curRot
|
||||||
|
+ "&tilt=" + curTilt
|
||||||
|
+ "&lat=" + (curLat / 1000f)
|
||||||
|
+ "&lon=" + (curLon / 1000f))
|
||||||
.buildString();
|
.buildString();
|
||||||
Window.Location.replace(newURL);
|
Window.Location.replace(newURL);
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,13 @@ public class GwtGraphics implements Graphics {
|
|||||||
context.viewport(0, 0, config.width, config.height);
|
context.viewport(0, 0, config.width, config.height);
|
||||||
|
|
||||||
// this actually *enables* the option to use std derivatives in shader..
|
// this actually *enables* the option to use std derivatives in shader..
|
||||||
context.getExtension("OES_standard_derivatives");
|
if (context.getExtension("OES_standard_derivatives") == null) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if (context.getExtension("WEBKIT_WEBGL_depth_texture") == null) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
this.gl = config.useDebugGL ? new GwtGL20Debug(context) : new GwtGLAdapter(context);
|
this.gl = config.useDebugGL ? new GwtGL20Debug(context) : new GwtGLAdapter(context);
|
||||||
canvas.setId("gdx-canvas");
|
canvas.setId("gdx-canvas");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user