Zn2O / gwt-google-apis

Automatically exported from code.google.com/p/gwt-google-apis
0 stars 0 forks source link

Maps: Problem with custom projection in Hosted mode #180

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Found in Release:
Maps 1.0.0 (RC1)

Detailed description:
cyface (Tim White) reports:

 When defining a custom Projection using GWT 1.5.2 and gwt-maps-1.0
RC1, I can't seem to get around this:

 com.google.gwt.dev.shell.HostedModeException: Expected primitive type
boolean; actual value was undefined
       at com.google.gwt.dev.shell.JsValueGlue.get(JsValueGlue.java:51)
       at
com.google.gwt.dev.shell.ie.SwtOleGlue.convertVariantsToObjects(SwtOleGlue.java:
57)
       at
com.google.gwt.dev.shell.ie.IDispatchImpl.callMethod(IDispatchImpl.java:
119)
       at
com.google.gwt.dev.shell.ie.IDispatchProxy.invoke(IDispatchProxy.java:
155)
       at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:
294)
       at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:
194)
       at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:
117)
       at org.eclipse.swt.internal.ole.win32.COM.VtblCall(Native Method)
       at org.eclipse.swt.internal.ole.win32.IDispatch.Invoke(IDispatch.java:
64)
       at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:
493)
       at org.eclipse.swt.ole.win32.OleAutomation.invoke(OleAutomation.java:
417)
       at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvokeOnWindow(ModuleSpaceIE6.java:
67)
       at
com.google.gwt.dev.shell.ie.ModuleSpaceIE6.doInvoke(ModuleSpaceIE6.java:
152)
       at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:
447)
       at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeVoid(ModuleSpace.java:
248)
       at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeVoid(JavaScriptHost.java:
107)
       at
com.google.gwt.maps.client.impl.__MapImplImpl.checkResize(transient
source for com.google.gwt.maps.client.impl.__MapImplImpl)
       at com.google.gwt.maps.client.MapWidget.checkResize(MapWidget.java:
729)
       at com.google.gwt.maps.client.MapWidget.onAttach(MapWidget.java:1507)
       at com.google.gwt.user.client.ui.Widget.setParent(Widget.java:231)
       at com.google.gwt.user.client.ui.Panel.adopt(Panel.java:119)
       at com.google.gwt.user.client.ui.ComplexPanel.add(ComplexPanel.java:
86)
       at com.google.gwt.user.client.ui.AbsolutePanel.add(AbsolutePanel.java:
80)
       at
com.cyface.northmoor.map.client.NorthmoorMap.onModuleLoad(NorthmoorMap.java:
64)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
39)
       at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:
25)
       at java.lang.reflect.Method.invoke(Method.java:597)
       at com.google.gwt.dev.shell.ModuleSpace.onLoad(ModuleSpace.java:320)
       at
com.google.gwt.dev.shell.BrowserWidget.attachModuleSpace(BrowserWidget.java:
329)
       at com.google.gwt.dev.shell.ie.BrowserWidgetIE6.access
$300(BrowserWidgetIE6.java:37)
       at
com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.gwtOnLoad(BrowserWidgetIE6
.java:
76)
       at
com.google.gwt.dev.shell.ie.BrowserWidgetIE6$External.invoke(BrowserWidgetIE6.ja
va:
139)
       at
com.google.gwt.dev.shell.ie.IDispatchImpl.Invoke(IDispatchImpl.java:
294)
       at
com.google.gwt.dev.shell.ie.IDispatchImpl.method6(IDispatchImpl.java:
194)
       at
org.eclipse.swt.internal.ole.win32.COMObject.callback6(COMObject.java:
117)
       at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
       at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1925)
       at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2966)
       at com.google.gwt.dev.GWTShell.pumpEventLoop(GWTShell.java:720)
       at com.google.gwt.dev.GWTShell.run(GWTShell.java:593)
       at com.google.gwt.dev.GWTShell.main(GWTShell.java:357)

My projection class:

public class NorthmoorMapProjection extends Projection {
       int imageDimension = 65536;
       int maxZoom = 5;
       int tileSize = 256;
       Point[] pixelOrigin = new Point[maxZoom];
       int[] pixelsPerLonDegree = new int[maxZoom];
       int[] tileBounds = new int[maxZoom];
       boolean isWrapped = false;

       public NorthmoorMapProjection() {
               int currentTileSize = this.tileSize;
               int currentTileBounds = 1;
               for (int zoomLevel = 0; zoomLevel < this.maxZoom; zoomLevel++) {
                       int tileCenter = currentTileSize / 2;
                       this.pixelsPerLonDegree[zoomLevel] = currentTileSize
/ 360;
                       this.pixelOrigin[zoomLevel] =
Point.newInstance(tileCenter,
tileCenter);
                       this.tileBounds[zoomLevel] = currentTileBounds;
                       currentTileSize *= 2;
                       currentTileBounds *= 2;
               }
       }

       @Override
       public Point fromLatLngToPixel(LatLng latLng, int zoomLevel) {
               Point pixelOrigin = this.pixelOrigin[zoomLevel];
               int pixelOriginX = pixelOrigin.getX();
               int pixelOriginY = pixelOrigin.getY();
               int pixelsPerLonDegreeForCurrentZoom =
this.pixelsPerLonDegree[zoomLevel];
               double currentLongitude = latLng.getLongitude();
               double currentLatitude = latLng.getLatitude();
               long newX = Math.round(pixelOriginX + currentLongitude *
pixelsPerLonDegreeForCurrentZoom);
               long newY = Math.round(pixelOriginY + (-2 * currentLatitude) *
pixelsPerLonDegreeForCurrentZoom);
               int newXint = new Long(newX).intValue();
               int newYint = new Long(newY).intValue();
               return Point.newInstance(newXint, newYint);
       }

       @Override
       public LatLng fromPixelToLatLng(Point point, int zoomLevel, boolean
unbounded) {
               Point pixelOrigin = this.pixelOrigin[zoomLevel];
               int pixelOriginX = pixelOrigin.getX();
               int pixelOriginY = pixelOrigin.getY();
               int pixelsPerLonDegreeForCurrentZoom =
this.pixelsPerLonDegree[zoomLevel];
               int currentX = point.getX();
               int currentY = point.getY();
               double d = currentX - pixelOriginX /
pixelsPerLonDegreeForCurrentZoom;
               double e = -0.5 * (currentY - pixelOriginY) /
pixelsPerLonDegreeForCurrentZoom;
               return LatLng.newInstance(e, d, unbounded);

       }

       @Override
       public double getWrapWidth(int zoomLevel) {
               return this.tileBounds[zoomLevel] * this.tileSize;
       }

       @Override
       public boolean tileCheckRange(TileIndex index, int zoomLevel, int
tileSize) {
               int tileBounds = this.tileBounds[zoomLevel];
               int newX = index.getX();
               if (index.getY() < 0 || index.getY() >= tileBounds) {
                       return false;
               }
               if (this.isWrapped) {
                       if (index.getX() < 0 || index.getX() >= tileBounds) {
                               newX = index.getX() % tileBounds;
                               if (index.getX() < 0) {
                                       newX += tileBounds;
                               }
                       }
               } else {
                       if (index.getX() < 0 || index.getX() >= tileBounds) {
                               return false;
                       }
               }
               return true;
       }

Workaround if you have one:
none known.

Links to the relevant GWT Developer Forum posts:
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/d919fcbcc
aa1b02a

Original issue reported on code.google.com by galgwt.reviews@gmail.com on 26 Sep 2008 at 11:48

GoogleCodeExporter commented 9 years ago
Taking the projection class I reproduced the issue and tried to trace through 
it in
Hosted mode.

The problem is happening somewhere after these entry points return.

I added GWT.log() statements before each return in the tileCheckRange() 
statement but
then had trouble reproducing the problem.

I did experience a hosted mode crash (on Mac OS X 10.5) while trying to debug 
the
problem (crash pointed to invalid pointer ref in swt library)

Original comment by galgwt.reviews@gmail.com on 26 Sep 2008 at 11:51

GoogleCodeExporter commented 9 years ago
 com.google.gwt.dev.shell.HostedModeException: Expected primitive type
boolean; actual value was undefined 

The error is happening while hosted mode tries to pass the 3rd arg of
fromPixelToLatLng() - the "unbounded" parameter.

public LatLng fromPixelToLatLng(Point point, int zoomLevel, boolean unbounded);

Original comment by galgwt.reviews@gmail.com on 26 Sep 2008 at 1:38

GoogleCodeExporter commented 9 years ago
Discussion of proposed solutions are out for review on the 
Google-Web-Toolkit-Contributors group.

Original comment by ericzun...@gmail.com on 26 Sep 2008 at 8:43

GoogleCodeExporter commented 9 years ago
Committed fix for this issue in JSIO r89, and in Maps/Search in r860.

Original comment by galgwt.reviews@gmail.com on 1 Oct 2008 at 5:25

GoogleCodeExporter commented 9 years ago
Tested, and it works now!  Thanks!!!!

Original comment by cyf...@gmail.com on 3 Oct 2008 at 1:28

GoogleCodeExporter commented 9 years ago

Original comment by galgwt.reviews@gmail.com on 11 Dec 2008 at 3:08

GoogleCodeExporter commented 9 years ago
Updating account names

Original comment by zundel@google.com on 21 Dec 2009 at 1:59