Changeset 11975 in josm
- Timestamp:
- 2017-04-22T18:55:26+02:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/SyncEditorLayerIndex.groovy
r11968 r11975 197 197 myprintln "*** Loaded ${eliEntries.size()} entries (ELI). ***" 198 198 } 199 String cdata(def s) { 200 if(s =~ /[<>&]/) 199 String cdata(def s, boolean escape = false) { 200 if(escape) { 201 return s.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">") 202 } else if(s =~ /[<>&]/) 201 203 return "<![CDATA[$s]]>" 202 204 return s … … 204 206 205 207 String maininfo(def entry, String offset) { 206 String res = offset + "<type>${getType(entry)}</type>\n" 208 String t = getType(entry) 209 String res = offset + "<type>$t</type>\n" 207 210 res += offset + "<url>${cdata(getUrl(entry))}</url>\n" 208 if( getType(entry)== "tms") {211 if(t == "tms") { 209 212 if(getMinZoom(entry) != null) 210 213 res += offset + "<min-zoom>${getMinZoom(entry)}</min-zoom>\n" 211 214 if(getMaxZoom(entry) != null) 212 215 res += offset + "<max-zoom>${getMaxZoom(entry)}</max-zoom>\n" 216 } else if (t == "wms") { 217 def p = getProjections(entry) 218 if (p) { 219 res += offset + "<projections>\n" 220 for (def c : p) 221 res += offset + " <code>$c</code>\n" 222 res += offset + "</projections>\n" 223 } 213 224 } 214 225 return res … … 223 234 def best = "eli-best".equals(getQuality(e)) 224 235 stream.write " <entry"+(best ? " eli-best=\"true\"" : "" )+">\n" 225 stream.write " <name>${ getName(e)}</name>\n"236 stream.write " <name>${cdata(getName(e), true)}</name>\n" 226 237 stream.write " <id>${getId(e)}</id>\n" 227 238 def t … … 230 241 if((t = getCountryCode(e))) 231 242 stream.write " <country-code>$t</country-code>\n" 243 stream.write maininfo(e, " ") 244 if((t = getAttributionText(e))) 245 stream.write " <attribution-text mandatory=\"true\">${cdata(t, true)}</attribution-text>\n" 246 if((t = getAttributionUrl(e))) 247 stream.write " <attribution-url>${cdata(t)}</attribution-url>\n" 248 if((t = getTermsOfUseText(e))) 249 stream.write " <terms-of-use-text>${cdata(t, true)}</terms-of-use-text>\n" 250 if((t = getTermsOfUseUrl(e))) 251 stream.write " <terms-of-use-url>${cdata(t)}</terms-of-use-url>\n" 252 if((t = getPermissionReferenceUrl(e))) 253 stream.write " <permission-ref>${cdata(t)}</permission-ref>\n" 254 if((getValidGeoreference(e))) 255 stream.write " <valid-georeference>true</valid-georeference>\n" 232 256 if((t = getIcon(e))) 233 257 stream.write " <icon>${cdata(t)}</icon>\n" 234 stream.write maininfo(e, " ") 258 for (def d : getDescriptions(e)) { 259 stream.write " <description lang=\"${d.getKey()}\">${d.getValue()}</description>\n" 260 } 235 261 for (def m : getMirrors(e)) { 236 262 stream.write " <mirror>\n"+maininfo(m, " ")+" </mirror>\n" … … 616 642 return [] 617 643 } 644 static List<Object> getProjections(Object e) { 645 def r 646 if (e instanceof ImageryInfo) { 647 r = e.getServerProjections() 648 } else { 649 r = e.get("properties").get("available_projections") 650 } 651 return r ? r : [] 652 } 618 653 static List<Shape> getShapes(Object e) { 619 654 if (e instanceof ImageryInfo) { … … 680 715 return e.get("properties").getString("icon", null) 681 716 } 717 static String getAttributionText(Object e) { 718 if (e instanceof ImageryInfo) return e.getAttributionText(0, null, null) 719 try {return e.get("properties").get("attribution").getString("text", null)} catch (NullPointerException ex) {return null} 720 } 721 static String getAttributionUrl(Object e) { 722 if (e instanceof ImageryInfo) return e.getAttributionLinkURL() 723 try {return e.get("properties").get("attribution").getString("url", null)} catch (NullPointerException ex) {return null} 724 } 725 static String getTermsOfUseText(Object e) { 726 if (e instanceof ImageryInfo) return e.getTermsOfUseText() 727 return null 728 } 729 static String getTermsOfUseUrl(Object e) { 730 if (e instanceof ImageryInfo) return e.getTermsOfUseURL() 731 return null 732 } 733 static String getPermissionReferenceUrl(Object e) { 734 if (e instanceof ImageryInfo) return e.getPermissionReferenceURL() 735 return e.get("properties").getString("license_url", null) 736 } 737 static Map<String,String> getDescriptions(Object e) { 738 Map<String,String> res = new HashMap<String, String>() 739 if (e instanceof ImageryInfo) { 740 String a = e.getDescription() 741 if (a) res.put("en", a) 742 } else { 743 String a = e.get("properties").getString("description", null) 744 if (a) res.put("en", a) 745 } 746 return res 747 } 748 static Boolean getValidGeoreference(Object e) { 749 if (e instanceof ImageryInfo) return e.isGeoreferenceValid() 750 return false 751 } 682 752 String getDescription(Object o) { 683 753 def url = getUrl(o) -
trunk/src/org/openstreetmap/josm/data/imagery/ImageryInfo.java
r11889 r11975 175 175 /** Text of a text attribution displayed when using the imagery */ 176 176 private String attributionText; 177 /** Link behing the text attribution displayed when using the imagery */ 177 /** Link to a reference stating the permission for OSM usage */ 178 private String permissionReferenceURL; 179 /** Link behind the text attribution displayed when using the imagery */ 178 180 private String attributionLinkURL; 179 181 /** Image of a graphical attribution displayed when using the imagery */ … … 222 224 @pref String attribution_text; 223 225 @pref String attribution_url; 226 @pref String permission_reference_url; 224 227 @pref String logo_image; 225 228 @pref String logo_url; … … 265 268 attribution_text = i.attributionText; 266 269 attribution_url = i.attributionLinkURL; 270 permission_reference_url = i.permissionReferenceURL; 267 271 date = i.date; 268 272 bestMarked = i.bestMarked; … … 429 433 attributionText = e.attribution_text; 430 434 attributionLinkURL = e.attribution_url; 435 permissionReferenceURL = e.permission_reference_url; 431 436 attributionImage = e.logo_image; 432 437 attributionImageURL = e.logo_url; … … 470 475 this.attributionText = i.attributionText; 471 476 this.attributionLinkURL = i.attributionLinkURL; 477 this.permissionReferenceURL = i.permissionReferenceURL; 472 478 this.attributionImage = i.attributionImage; 473 479 this.attributionImageURL = i.attributionImageURL; … … 520 526 Objects.equals(this.attributionText, other.attributionText) && 521 527 Objects.equals(this.attributionLinkURL, other.attributionLinkURL) && 528 Objects.equals(this.permissionReferenceURL, other.permissionReferenceURL) && 522 529 Objects.equals(this.attributionImageURL, other.attributionImageURL) && 523 530 Objects.equals(this.attributionImage, other.attributionImage) && … … 633 640 } 634 641 642 /** 643 * Return the permission reference URL. 644 * @param url The url. 645 * @see #setPermissionReferenceURL() 646 * @since 11975 647 */ 648 public String getPermissionReferenceURL() { 649 return permissionReferenceURL; 650 } 651 635 652 @Override 636 653 public Image getAttributionImage() { … … 691 708 public void setAttributionLinkURL(String url) { 692 709 attributionLinkURL = url; 710 } 711 712 /** 713 * Sets the permission reference URL. 714 * @param url The url. 715 * @see #getPermissionReferenceURL() 716 * @since 11975 717 */ 718 public void setPermissionReferenceURL(String url) { 719 permissionReferenceURL = url; 693 720 } 694 721 -
trunk/src/org/openstreetmap/josm/io/imagery/ImageryReader.java
r11913 r11975 197 197 "terms-of-use-text", 198 198 "terms-of-use-url", 199 "permission-ref", 199 200 "country-code", 200 201 "icon", … … 437 438 entry.setTermsOfUseText(accumulator.toString()); 438 439 break; 440 case "permission-ref": 441 entry.setPermissionReferenceURL(accumulator.toString()); 442 break; 439 443 case "terms-of-use-url": 440 444 entry.setTermsOfUseURL(accumulator.toString());
Note:
See TracChangeset
for help on using the changeset viewer.