Changeset 26808 in osm for applications/editors
- Timestamp:
- 2011-10-08T18:22:33+02:00 (13 years ago)
- Location:
- applications/editors/josm/plugins/imagery-xml-bounds
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/imagery-xml-bounds/build.xml
r26781 r26808 32 32 <property name="commit.message" value="Commit message"/> 33 33 <!-- enter the *lowest* JOSM version this plugin is currently compatible with --> 34 <property name="plugin.main.version" value="4 488"/>34 <property name="plugin.main.version" value="4506"/> 35 35 <!-- should not be necessary to change the following properties --> 36 36 <property name="josm" location="../../core/dist/josm-custom.jar"/> -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/ImageryXmlBoundsPlugin.java
r26776 r26808 27 27 28 28 /** 29 * Main class of Imagery X LMbounds plugin.29 * Main class of Imagery XML bounds plugin. 30 30 * @author Don-vip 31 * @version 1. 031 * @version 1.1 32 32 * History: 33 * 2.0 03-Oct-2011 first version 33 * 1.1 08-Oct-2011 Update for #6934 and JOSM 4506, code refactorisation, removing debug code 34 * 1.0 03-Oct-2011 first version 34 35 */ 35 36 public class ImageryXmlBoundsPlugin extends Plugin { -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/XmlBoundsConstants.java
r26776 r26808 33 33 * Plugin version. 34 34 */ 35 public static final String PLUGIN_VERSION = "1. 0";35 public static final String PLUGIN_VERSION = "1.1"; 36 36 37 37 /** … … 45 45 public static final String XML_SCHEMA = "resource://data/maps.xsd"; 46 46 47 /** 48 * Prefix used in front of OSM keys. 49 */ 50 public static final String PREFIX = "imagery:"; 51 47 /** 48 * XML tags 49 */ 50 public static final String XML_NAME = "name"; 51 public static final String XML_TYPE = "type"; 52 public static final String XML_URL = "url"; 53 public static final String XML_DEFAULT = "default"; 54 public static final String XML_EULA = "eula"; 55 public static final String XML_ATTR_TEXT = "attribution-text"; 56 public static final String XML_ATTR_URL = "attribution-url"; 57 public static final String XML_TERMS_TEXT = "terms-of-use-text"; 58 public static final String XML_TERMS_URL = "terms-of-use-url"; 59 public static final String XML_PROJECTIONS = "projections"; 60 public static final String XML_MAX_ZOOM = "max-zoom"; 61 public static final String XML_MIN_ZOOM = "min-zoom"; 62 public static final String XML_COUNTRY_CODE = "country-code"; 63 public static final String XML_LOGO_IMAGE = "logo-image";// TODO 64 public static final String XML_LOGO_URL = "logo-url"; 65 66 /** 67 * Prefix used in front of OSM keys. 68 */ 69 public static final String PREFIX = "imagery:"; 70 52 71 /** 53 72 * OSM keys, equivalent to those used in XML schema, but prefixed (except for name). 54 73 */ 55 public static final String KEY_NAME = "name"; 56 public static final String KEY_TYPE = PREFIX + "type"; 57 public static final String KEY_URL = PREFIX + "url"; 58 public static final String KEY_DEFAULT = PREFIX + "default"; 59 public static final String KEY_EULA = PREFIX + "eula"; 60 public static final String KEY_ATTR_TEXT = PREFIX + "attribution-text"; 61 public static final String KEY_ATTR_URL = PREFIX + "attribution-url"; 62 public static final String KEY_TERMS_URL = PREFIX + "terms-of-use-url"; 63 public static final String KEY_PROJECTIONS = PREFIX + "projections"; 64 public static final String KEY_MAX_ZOOM = PREFIX + "max-zoom"; 65 public static final String KEY_MIN_ZOOM = PREFIX + "min-zoom"; 66 public static final String KEY_COUNTRY_CODE = PREFIX + "country-code"; 74 public static final String KEY_NAME = XML_NAME; 75 public static final String KEY_TYPE = PREFIX + XML_TYPE; 76 public static final String KEY_URL = PREFIX + XML_URL; 77 public static final String KEY_DEFAULT = PREFIX + XML_DEFAULT; 78 public static final String KEY_EULA = PREFIX + XML_EULA; 79 public static final String KEY_ATTR_TEXT = PREFIX + XML_ATTR_TEXT; 80 public static final String KEY_ATTR_URL = PREFIX + XML_ATTR_URL; 81 public static final String KEY_TERMS_TEXT = PREFIX + XML_TERMS_TEXT; 82 public static final String KEY_TERMS_URL = PREFIX + XML_TERMS_URL; 83 public static final String KEY_PROJECTIONS = PREFIX + XML_PROJECTIONS; 84 public static final String KEY_MAX_ZOOM = PREFIX + XML_MAX_ZOOM; 85 public static final String KEY_MIN_ZOOM = PREFIX + XML_MIN_ZOOM; 86 public static final String KEY_COUNTRY_CODE = PREFIX + XML_COUNTRY_CODE; 87 public static final String KEY_LOGO_IMAGE = PREFIX + XML_LOGO_IMAGE;// TODO 88 public static final String KEY_LOGO_URL = PREFIX + XML_LOGO_URL; 67 89 68 90 /** -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/XmlBoundsImporter.java
r26776 r26808 148 148 safePut(osmImagery, KEY_PROJECTIONS, imagery.getServerProjections()); 149 149 safePut(osmImagery, KEY_EULA, imagery.getEulaAcceptanceRequired()); 150 safePut(osmImagery, KEY_ATTR_TEXT, imagery.getAttributionText( ));150 safePut(osmImagery, KEY_ATTR_TEXT, imagery.getAttributionText(0, null, null)); 151 151 safePut(osmImagery, KEY_ATTR_URL, imagery.getAttributionLinkURL()); 152 safePut(osmImagery, KEY_TERMS_TEXT, imagery.getTermsOfUseText()); 152 153 safePut(osmImagery, KEY_TERMS_URL, imagery.getTermsOfUseURL()); 153 154 safePut(osmImagery, KEY_COUNTRY_CODE, imagery.getCountryCode()); 155 safePut(osmImagery, KEY_LOGO_URL, imagery.getAttributionImageURL()); 154 156 155 157 if (imagery.getImageryType().equals(ImageryType.TMS)) { -
applications/editors/josm/plugins/imagery-xml-bounds/src/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/ComputeBoundsAction.java
r26776 r26808 120 120 } 121 121 122 protected static final String startTag(String tag) { 123 return "<" + tag + ">"; 124 } 125 126 protected static final String startMandatoryTag(String tag) { 127 return "<" + tag + " mandatory='true'>"; 128 } 129 130 protected static final String endTag(String tag) { 131 return "</" + tag + ">"; 132 } 133 134 protected static final String simpleTag(String tag, String content) { 135 return simpleTag(tag, content, ""); 136 } 137 138 protected static final String simpleTag(String tag, String content, boolean escape) { 139 return simpleTag(tag, content, "", escape); 140 } 141 142 protected static final String simpleTag(String tag, String content, String def) { 143 return simpleTag(tag, content, def, true); 144 } 145 146 protected static final String simpleTag(String tag, String content, String def, boolean escape) { 147 return startTag(tag) + (content != null 148 ? (escape ? escapeReservedCharacters(content) : content) 149 : def 150 ) + endTag(tag); 151 } 152 153 protected static final String mandatoryTag(String tag, String content) { 154 return mandatoryTag(tag, content, true); 155 } 156 157 protected static final String mandatoryTag(String tag, String content, boolean escape) { 158 return startMandatoryTag(tag) + (escape ? escapeReservedCharacters(content) : content) + endTag(tag); 159 } 160 161 public static String escapeReservedCharacters(String s) { 162 return s == null ? "" : s.replace("&", "&").replace("<", "<").replace(">", ">"); 163 } 164 122 165 protected static final String getXml(OsmPrimitive ... primitives) { 123 166 List<String> entries = new ArrayList<String>(); … … 144 187 145 188 protected static final String getEntry(OsmPrimitive p, String bounds) { 146 return getEntry(p.get(KEY_NAME), p.get(KEY_TYPE), p.get(KEY_URL), bounds, p.get(KEY_PROJECTIONS), p.get(KEY_EULA), p.get(KEY_ATTR_TEXT), p.get(KEY_ATTR_URL), p.get(KEY_COUNTRY_CODE)); 147 } 148 149 protected static final String getEntry(String name, String type, String url, String bounds, String projections, String eula, String attributionText, String attributionUrl, String countryCode) { 189 return getEntry(p.get(KEY_NAME), p.get(KEY_TYPE), p.get(KEY_DEFAULT), p.get(KEY_URL), bounds, p.get(KEY_PROJECTIONS), p.get(KEY_LOGO_URL), 190 p.get(KEY_EULA), p.get(KEY_ATTR_TEXT), p.get(KEY_ATTR_URL), p.get(KEY_TERMS_TEXT), p.get(KEY_TERMS_URL), p.get(KEY_COUNTRY_CODE), p.get(KEY_MAX_ZOOM), p.get(KEY_MIN_ZOOM)); 191 } 192 193 protected static final boolean isSet(String tag) { 194 return tag != null && !tag.isEmpty(); 195 } 196 197 protected static final String getEntry(String name, String type, String def, String url, String bounds, String projections, String logoURL, 198 String eula, String attributionText, String attributionUrl, String termsText, String termsUrl, String countryCode, String maxZoom, String minZoom) { 150 199 String result = 151 200 " <entry>\n"+ 152 " <name>"+ (name != null ? name : "") +"</name>\n"+153 " <type>"+ (type != null ? type : "wms") +"</type>\n"+154 " <url>" + (url != null ? encodeUrl(url) : "") +"</url>\n"+201 " " + simpleTag(XML_NAME, name) + "\n"+ 202 " " + simpleTag(XML_TYPE, type, "wms") + "\n"+ 203 " " + simpleTag(XML_URL, url != null ? encodeUrl(url) : "") + "\n"+ 155 204 bounds+"\n"; 156 205 if (projections != null && !projections.isEmpty()) { 157 result += " <projections>\n";206 result += " "+startTag(XML_PROJECTIONS)+"\n"; 158 207 int i = 0; 159 208 String[] codes = projections.split(";"); … … 162 211 result += " "; 163 212 } 164 result += "<code>"+code.trim()+"</code>";213 result += simpleTag("code", code.trim()); 165 214 if (i%6 == 5 || i == codes.length-1 ) { 166 215 result += "\n"; … … 168 217 i++; 169 218 } 170 result += " </projections>\n"; 171 } 172 if (eula != null && !eula.isEmpty()) { 173 result += " <eula mandatory='true'>"+encodeUrl(eula)+"></eula>\n"; 174 } 175 if (attributionText != null && !attributionText.isEmpty()) { 176 result += " <attribution-text mandatory='true'>"+attributionText+"</attribution-text>\n"; 177 } 178 if (attributionUrl != null && !attributionUrl.isEmpty()) { 179 result += " <attribution-url>"+encodeUrl(attributionUrl)+"</attribution-url>\n"; 180 } 181 if (countryCode != null && !countryCode.isEmpty()) { 182 result += " <country-code>"+countryCode+"</country-code>\n"; 219 result += " "+endTag(XML_PROJECTIONS)+"\n"; 220 } 221 if (isSet(def) && def.equals("true")) { 222 result += " " + simpleTag(XML_DEFAULT, def) + "\n"; 223 } 224 if (isSet(eula)) { 225 result += " " + mandatoryTag(XML_EULA, encodeUrl(eula), false) + "\n"; 226 } 227 if (isSet(attributionText)) { 228 result += " " + mandatoryTag(XML_ATTR_TEXT, attributionText) + "\n"; 229 } 230 if (isSet(attributionUrl)) { 231 result += " " + simpleTag(XML_ATTR_URL, encodeUrl(attributionUrl), false) + "\n"; 232 } 233 if (isSet(termsText)) { 234 result += " " + simpleTag(XML_TERMS_TEXT, termsText) + "\n"; 235 } 236 if (isSet(termsUrl)) { 237 result += " " + simpleTag(XML_TERMS_URL, encodeUrl(termsUrl), false) + "\n"; 238 } 239 if (isSet(logoURL)) { 240 result += " " + simpleTag(XML_LOGO_URL, encodeUrl(logoURL), false) + "\n"; 241 } 242 if (isSet(countryCode)) { 243 result += " " + simpleTag(XML_COUNTRY_CODE, countryCode) + "\n"; 244 } 245 if ("tms".equals(type)) { 246 if (isSet(maxZoom)) { 247 result += " " + simpleTag(XML_MAX_ZOOM, maxZoom) + "\n"; 248 } 249 if (isSet(minZoom)) { 250 result += " " + simpleTag(XML_MIN_ZOOM, minZoom) + "\n"; 251 } 183 252 } 184 253 result += " </entry>"; … … 253 322 } 254 323 255 boolean result =latMap.size() == 2 && lonMap.size() == 2324 return latMap.size() == 2 && lonMap.size() == 2 256 325 && latMap.containsKey(bBox.getBottomRight().lat()) && latMap.containsKey(bBox.getTopLeft().lat()) 257 326 && lonMap.containsKey(bBox.getBottomRight().lon()) && lonMap.containsKey(bBox.getTopLeft().lon()); 258 System.out.println(result);259 return result;260 327 } 261 328 return false;
Note:
See TracChangeset
for help on using the changeset viewer.