source: josm/trunk/src/org/openstreetmap/josm/io/WMSLayerExporter.java@ 8995

Last change on this file since 8995 was 8526, checked in by wiktorn, 9 years ago

Introduce WMS layer based on TMS. (closes: #11255)

HEADS UP: After this patch you need to manually remove JAX-B generated file/class: org/w3/_2001/xmlschema/Adapter1.java to compile the tree again.

  • create AbstractTileSourceLayer based on TMSLayer as a base for TMS, WMS and (future) WMTS layers, (addresses #11459)
  • WMS layer now uses JCS Caching (closes: #7363)
  • introduce new conversion methods in TileSource, that convert both X and Y (lat and lon) in one call. This is necessary for other than PseudoMercator projections
    • introduce TileXY class that represents X and Y indexes of tile in tile matrix/space
    • mark old conversion methods as deprecated
    • refactor JMapViewer and JOSM to new methods
    • change use of Coordinate class to ICoordinate where appropiate
  • extract CachedAttributionBingAerialTileSource to separate file
  • create TemplatedWMSTileSource that provides the WMS Layer with square (according to current projection) tiles (closes: #11572, closes: #7682, addresses: #5454)
  • implemented precaching imagery along GPX track for AbstractTileSourceLayer, so now it work for both - WMS and TMS (closes: #9154)
  • implemented common righ-click menu on map view, as well on layer list (closes #3591)
  • create separate build commands for JMapViewer classes to easily spot, when josm classes are used within JMapViewer
  • remove unnecessary classes of previous WMS implementation - GeorefImage, wms-cache.xsd (and JAXB task from build), WMSCache, WMSRequest, WMSGrabber, HTMLGrabber, WMSException
  • Property svn:eol-style set to native
File size: 1.8 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.io;
3
4import java.io.File;
5import java.io.FileOutputStream;
6import java.io.IOException;
7import java.io.ObjectOutputStream;
8
9import org.openstreetmap.josm.Main;
10import org.openstreetmap.josm.data.Preferences;
11import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryPreferenceEntry;
12import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
13import org.openstreetmap.josm.gui.layer.Layer;
14import org.openstreetmap.josm.tools.CheckParameterUtil;
15
16/**
17 * Export a WMS layer to a serialized binary file that can be imported later via {@link WMSLayerImporter}.
18 *
19 * @since 5457
20 */
21public class WMSLayerExporter extends FileExporter {
22
23 /** Which version of the file we export */
24 public static final int CURRENT_FILE_VERSION = 6;
25
26 /**
27 * Constructs a new {@code WMSLayerExporter}
28 */
29 public WMSLayerExporter() {
30 super(WMSLayerImporter.FILE_FILTER);
31 }
32
33 @Override
34 public void exportData(File file, Layer layer) throws IOException {
35 CheckParameterUtil.ensureParameterNotNull(file, "file");
36 CheckParameterUtil.ensureParameterNotNull(layer, "layer");
37
38 if (layer instanceof AbstractTileSourceLayer) {
39 try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(file))) {
40 oos.writeInt(CURRENT_FILE_VERSION); // file version
41 oos.writeObject(Main.map.mapView.getCenter());
42 ImageryPreferenceEntry entry = new ImageryPreferenceEntry(((AbstractTileSourceLayer) layer).getInfo());
43 oos.writeObject(Preferences.serializeStruct(entry, ImageryPreferenceEntry.class));
44 }
45 }
46
47 }
48
49 @Override
50 public void activeLayerChange(Layer oldLayer, Layer newLayer) {
51 setEnabled(newLayer instanceof AbstractTileSourceLayer);
52 }
53}
Note: See TracBrowser for help on using the repository browser.