Index: C:/work/workspace2/maven.1208695595359/geowebcache/src/test/java/org/geowebcache/service/mgmaps/MGMapsConverterTest.java
===================================================================
--- C:/work/workspace2/maven.1208695595359/geowebcache/src/test/java/org/geowebcache/service/mgmaps/MGMapsConverterTest.java	(revision 0)
+++ C:/work/workspace2/maven.1208695595359/geowebcache/src/test/java/org/geowebcache/service/mgmaps/MGMapsConverterTest.java	(revision 0)
@@ -0,0 +1,55 @@
+package org.geowebcache.service.mgmaps;
+
+import java.util.Arrays;
+
+import junit.framework.TestCase;
+
+public class MGMapsConverterTest extends TestCase {
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+    }
+
+    /**
+     * see
+     * Modified for MGMaps API
+     * 
+     * @throws Exception
+     */
+    public void testMGMapsConverter() throws Exception {
+    	/* Check origin location */
+    	int x = 0; int y = 0; int z = 17;
+    	int[] gridLoc = MGMapsConverter.convert(z, x, y);
+    	int[] solution = {0,0,0};
+    	
+    	assert(Arrays.equals(gridLoc, solution));
+    	
+    	/* Check zoomlevel */
+    	x = 0; y = 0; z = 17-1;
+    	solution[0] = 0; solution[1] = 1; solution[2] = 1;
+    	gridLoc = MGMapsConverter.convert(z, x, y);
+    	assert(Arrays.equals(gridLoc, solution));
+    	
+    	/* Check top right */
+    	x = 1; y = 0; z = 17-1;
+    	solution[0] = 1; solution[1] = 1; solution[2] = 1;
+    	gridLoc = MGMapsConverter.convert(z, x, y);
+    	assert(Arrays.equals(gridLoc, solution));
+    	
+    	/* Check top right, zoomlevel */
+    	x = 3; y = 0; z = 17-2;
+    	solution[0] = 3; solution[1] = 3; solution[2] = 2;
+    	gridLoc = MGMapsConverter.convert(z, x, y);
+    	assert(Arrays.equals(gridLoc, solution));
+    	
+    	/* Check middle */
+    	x = 2; y = 1; z = 17-2;
+    	solution[0] = 2; solution[1] = 2; solution[2] = 2;
+    	gridLoc = MGMapsConverter.convert(z, x, y);
+    	assert(Arrays.equals(gridLoc, solution));
+    	
+    	//System.out.println(Arrays.toString(solution));
+    	//System.out.println(Arrays.toString(gridLoc));
+    }
+}
\ No newline at end of file
Index: C:/work/workspace2/maven.1208695595359/geowebcache/src/main/java/org/geowebcache/service/mgmaps/MGMapsConverter.java
===================================================================
--- C:/work/workspace2/maven.1208695595359/geowebcache/src/main/java/org/geowebcache/service/mgmaps/MGMapsConverter.java	(revision 0)
+++ C:/work/workspace2/maven.1208695595359/geowebcache/src/main/java/org/geowebcache/service/mgmaps/MGMapsConverter.java	(revision 0)
@@ -0,0 +1,108 @@
+/**
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public License
+ *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * 
+ * @author Arne Kepp, The Open Planning Project, Copyright 2008
+ */
+package org.geowebcache.service.mgmaps;
+
+import java.util.Map;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.geowebcache.layer.SRS;
+import org.geowebcache.layer.TileLayer;
+import org.geowebcache.layer.TileRequest;
+import org.geowebcache.mime.MimeException;
+import org.geowebcache.mime.MimeType;
+import org.geowebcache.service.Service;
+import org.geowebcache.service.ServiceException;
+import org.geowebcache.service.ServiceRequest;
+import org.geowebcache.util.ServletUtils;
+
+/**
+ * Class to convert from Google Maps coordinates into the internal
+ * representation of a tile.
+ */
+public class MGMapsConverter extends Service {
+    public static final String SERVICE_MGMAPS = "mgmaps";
+
+    private static Log log = LogFactory
+            .getLog(org.geowebcache.service.mgmaps.MGMapsConverter.class);
+
+    public MGMapsConverter() {
+        super(SERVICE_MGMAPS);
+    }
+
+    public ServiceRequest getServiceRequest(HttpServletRequest request)  throws ServiceException {
+        return new ServiceRequest(super.getLayersParameter(request));
+    }
+
+    public TileRequest getTileRequest(TileLayer tileLayer, HttpServletRequest request)
+    throws ServiceException {
+        Map params = request.getParameterMap();
+        
+        String mimeType = ServletUtils.stringFromMap(params, "format");
+        String strZoom = ServletUtils.stringFromMap(params, "zoom");
+        String strX = ServletUtils.stringFromMap(params, "x");
+        String strY = ServletUtils.stringFromMap(params, "y");
+
+        int[] gridLoc = MGMapsConverter.convert(Integer.parseInt(strZoom), Integer
+                .parseInt(strX), Integer.parseInt(strY));
+        
+        SRS srs = new SRS(900913);
+        
+        MimeType mime = null; 
+        try {
+            if(mimeType == null) {
+                mimeType = "image/png";
+            }
+            mime = MimeType.createFromMimeType(mimeType);
+        } catch (MimeException me) {
+            throw new ServiceException("Unable to determine requested format, " + mimeType);
+        }
+        return new TileRequest(gridLoc,mime,srs);
+    }
+
+    /**
+     * Convert Google's tiling coordinates into an {x,y,x}
+     * 
+     * see
+     * http://code.google.com/apis/maps/documentation/overlays.html#Custom_Map_Types
+     * Modified by JaakL for mgmaps zoom understanding
+     * @param quadKey
+     * @return
+     */
+    public static int[] convert(int zoomLevel, int x, int y) {
+        // Extent is the total number of tiles in y direction
+    	int newZoom=17-zoomLevel;
+        int extent = (int) Math.pow(2, newZoom);
+
+        if (x < 0 || x > extent - 1) {
+            log.error("The X coordinate is not sane: " + x);
+            return null;
+        }
+
+        if (y < 0 || y > extent - 1) {
+            log.error("The Y coordinate is not sane: " + y);
+            return null;
+        }
+
+        // xPos and yPos correspond to the top left hand corner
+        int[] gridLoc = { x, extent - y - 1, newZoom};
+
+        return gridLoc;
+    }
+}
Index: C:/work/workspace2/maven.1208695595359/geowebcache/src/main/resources/applicationContext.xml
===================================================================
--- C:/work/workspace2/maven.1208695595359/geowebcache/src/main/resources/applicationContext.xml	(revision 154)
+++ C:/work/workspace2/maven.1208695595359/geowebcache/src/main/resources/applicationContext.xml	(working copy)
@@ -57,7 +57,9 @@
   <bean id="serviceWMS" 
     	class="org.geowebcache.service.wms.WMSService"/>
   <bean id="serviceGMaps"
-	class="org.geowebcache.service.gmaps.GMapsConverter"/>
+	class="org.geowebcache.service.gmaps.GMapsConverter"/>
+  <bean id="serviceMGMaps"
+	class="org.geowebcache.service.mgmaps.MGMapsConverter"/>
   <bean id="serviceVE"
 	class="org.geowebcache.service.ve.VEConverter"/>
   <bean id="serviceKML"
Index: C:/work/workspace2/maven.1208695595359/geowebcache/pom.xml
===================================================================
--- C:/work/workspace2/maven.1208695595359/geowebcache/pom.xml	(revision 154)
+++ C:/work/workspace2/maven.1208695595359/geowebcache/pom.xml	(working copy)
@@ -4,7 +4,7 @@
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.opengeo</groupId>
   <artifactId>geowebcache</artifactId>
-  <packaging>jar</packaging>
+  <packaging>war</packaging>
   <version>1.0-SNAPSHOT</version>
   <name>geowebcache</name>
   <url>http://geowebcache.org</url>
