gushoubang 11 сар өмнө
parent
commit
ca2acd187c

+ 0 - 62
onemap-modules/onemap-spatial/src/test/java/OnlineMap.java

@@ -1,62 +0,0 @@
-import org.geotools.geometry.jts.ReferencedEnvelope;
-import org.geotools.map.MapContent;
-
-import org.geotools.geometry.jts.ReferencedEnvelope;
-import org.geotools.map.MapContent;
-import org.geotools.map.TileLayer;
-import org.geotools.ows.ServiceException;
-import org.geotools.swing.JMapFrame;
-import org.geotools.tile.TileService;
-import org.geotools.tile.TileServiceInfo;
-import org.geotools.tile.impl.WebMercatorTileService;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.FactoryException;
-import org.opengis.referencing.NoSuchAuthorityCodeException;
-import org.geotools.referencing.CRS;
-
-import java.awt.*;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import javax.imageio.ImageIO;
-
-public class OnlineMap {
-
-    public static void main(String[] args) throws Exception {
-        // Set up the tile service URL
-        String urlTemplate = "http://ecn.t3.tiles.virtualearth.net/tiles/a{q}.jpeg?g=1";
-        TileService service = new WebMercatorTileService("Bing Aerial", urlTemplate, 18, 2, 256, 256);
-
-        // Create map content
-        MapContent mapContent = new MapContent();
-        mapContent.setTitle("Bing Aerial Map");
-
-        // Create tile layer
-        TileLayer tileLayer = new TileLayer(new TileServiceInfo(service));
-        mapContent.addLayer(tileLayer);
-
-        // Define the vector range (bounding box) for the area of interest
-        CoordinateReferenceSystem crs = CRS.decode("EPSG:3857");
-        ReferencedEnvelope bbox = new ReferencedEnvelope(-8238304.0, -8238304.0 + 100000, 4970240.0, 4970240.0 + 100000, crs);
-
-        // Display the map
-        JMapFrame mapFrame = new JMapFrame(mapContent);
-        mapFrame.setSize(800, 600);
-        mapFrame.setVisible(true);
-        mapFrame.getMapPane().setDisplayArea(bbox);
-
-        // Set up the screenshot area
-        Rectangle screenRect = new Rectangle(800, 600);
-        BufferedImage bufferedImage = new BufferedImage(screenRect.width, screenRect.height, BufferedImage.TYPE_INT_RGB);
-        Graphics2D graphics = bufferedImage.createGraphics();
-
-        // Render the map to the image
-        mapFrame.getMapPane().paint(graphics);
-
-        // Save the screenshot
-        ImageIO.write(bufferedImage, "png", new File("screenshot.png"));
-
-        // Release resources
-        graphics.dispose();
-        mapContent.dispose();
-    }
-}