Changeset 14638 in josm
- Timestamp:
- 2019-01-04T22:24:55+01:00 (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/build.xml
r14637 r14638 962 962 <exclude name="org/openstreetmap/josm/gui/mappaint/mapcss/parsergen/*.java" /> 963 963 </fileset> 964 <fileset dir="${base.dir}/scripts" includes="**/*.java"/> 964 965 </pmd> 965 966 </target> -
trunk/scripts/BuildProjectionDefinitions.java
r14637 r14638 1 1 // License: GPL. For details, see LICENSE file. 2 2 3 import java.io.BufferedWriter; 4 import java.io.File; 5 import java.io.FileOutputStream; 3 import java.io.BufferedReader; 6 4 import java.io.IOException; 7 import java.io. OutputStreamWriter;5 import java.io.Writer; 8 6 import java.nio.charset.StandardCharsets; 7 import java.nio.file.Files; 8 import java.nio.file.Path; 9 import java.nio.file.Paths; 9 10 import java.util.Arrays; 10 import java.util.Collections;11 11 import java.util.LinkedHashMap; 12 12 import java.util.List; … … 16 16 import java.util.regex.Matcher; 17 17 import java.util.regex.Pattern; 18 import java.util.stream.Collectors; 18 19 19 20 import org.openstreetmap.josm.data.projection.CustomProjection; … … 43 44 44 45 // statistics: 45 private static int noInJosm = 0;46 private static int noInProj4 = 0;47 private static int noDeprecated = 0;48 private static int noGeocent = 0;49 private static int noBaseProjection = 0;50 private static int noEllipsoid = 0;51 private static int noNadgrid = 0;52 private static int noDatumgrid = 0;53 private static int noJosm = 0;54 private static int noProj4 = 0;55 private static int noEsri = 0;56 private static int noOmercNoBounds = 0;57 private static int noEquatorStereo = 0;46 private static int noInJosm; 47 private static int noInProj4; 48 private static int noDeprecated; 49 private static int noGeocent; 50 private static int noBaseProjection; 51 private static int noEllipsoid; 52 private static int noNadgrid; 53 private static int noDatumgrid; 54 private static int noJosm; 55 private static int noProj4; 56 private static int noEsri; 57 private static int noOmercNoBounds; 58 private static int noEquatorStereo; 58 59 59 60 private static final Map<String, Integer> baseProjectionMap = new TreeMap<>(); … … 77 78 } 78 79 79 static List<String> initList(String baseDir, String ext) { 80 String[] result = new File(baseDir + File.separator + PROJ_DIR) 81 .list((dir, name) -> !name.contains(".") || name.toLowerCase(Locale.ENGLISH).endsWith(ext)); 82 return result != null ? Arrays.asList(result) : Collections.emptyList(); 80 static List<String> initList(String baseDir, String ext) throws IOException { 81 return Files.list(Paths.get(baseDir).resolve(PROJ_DIR)) 82 .map(path -> path.getFileName().toString()) 83 .filter(name -> !name.contains(".") || name.toLowerCase(Locale.ENGLISH).endsWith(ext)) 84 .collect(Collectors.toList()); 83 85 } 84 86 85 87 static void initMap(String baseDir, String file, Map<String, ProjectionDefinition> map) throws IOException { 86 List<ProjectionDefinition> list = Projections.loadProjectionDefinitions( 87 baseDir + File.separator + PROJ_DIR + File.separator + file); 88 final Path path = Paths.get(baseDir).resolve(PROJ_DIR).resolve(file); 89 final List<ProjectionDefinition> list; 90 try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { 91 list = Projections.loadProjectionDefinitions(reader); 92 } 88 93 if (list.isEmpty()) 89 94 throw new AssertionError("EPSG file seems corrupted"); … … 109 114 knownNadgrids = initList(baseDir, ".gsb"); 110 115 111 try (FileOutputStream output = new FileOutputStream(baseDir + File.separator + OUTPUT_EPSG_FILE); 112 BufferedWriter out = new BufferedWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8))) { 116 try (Writer out = Files.newBufferedWriter(Paths.get(baseDir).resolve(OUTPUT_EPSG_FILE), StandardCharsets.UTF_8)) { 113 117 out.write("## This file is autogenerated, do not edit!\n"); 114 118 out.write("## Run ant task \"epsg\" to rebuild.\n"); … … 180 184 } 181 185 182 static void write( BufferedWriter out, ProjectionDefinition pd) throws IOException {186 static void write(Writer out, ProjectionDefinition pd) throws IOException { 183 187 out.write("# " + pd.name + "\n"); 184 188 out.write("<"+pd.code.substring("EPSG:".length())+"> "+pd.definition+" <>\n"); … … 246 250 parameters = CustomProjection.parseParameterList(pd.definition, true); 247 251 } catch (ProjectionConfigurationException ex) { 248 throw new RuntimeException(pd.code+":"+ex);252 throw new IllegalStateException(pd.code + ":" + ex, ex); 249 253 } 250 254 String proj = parameters.get(CustomProjection.Param.proj.key); … … 306 310 } 307 311 308 final double EPS10 = 1.e-10;312 final double eps10 = 1.e-10; 309 313 310 314 String lat0 = parameters.get("lat_0"); … … 313 317 final double latitudeOfOrigin = Math.toRadians(CustomProjection.parseAngle(lat0, Param.lat_0.key)); 314 318 // TODO: implement equatorial stereographic, see https://josm.openstreetmap.de/ticket/15970 315 if (result && "stere".equals(proj) && Math.abs(latitudeOfOrigin) < EPS10) {319 if (result && "stere".equals(proj) && Math.abs(latitudeOfOrigin) < eps10) { 316 320 result = false; 317 321 noEquatorStereo++; … … 320 324 // exclude entries which need geodesic computation (equatorial/oblique azimuthal equidistant) 321 325 if (result && "aeqd".equals(proj)) { 322 final double HALF_PI= Math.PI / 2;323 if (Math.abs(latitudeOfOrigin - HALF_PI) >= EPS10 &&324 Math.abs(latitudeOfOrigin + HALF_PI) >= EPS10) {326 final double halfPi = Math.PI / 2; 327 if (Math.abs(latitudeOfOrigin - halfPi) >= eps10 && 328 Math.abs(latitudeOfOrigin + halfPi) >= eps10) { 325 329 // See https://josm.openstreetmap.de/ticket/16129#comment:21 326 330 result = false; … … 338 342 } 339 343 340 String k _0 = parameters.get("k_0");341 if (result && k _0 != null && k_0.startsWith("-")) {344 String k0 = parameters.get("k_0"); 345 if (result && k0 != null && k0.startsWith("-")) { 342 346 // Proj fails with "k <= 0" for ESRI:102470 343 347 result = false; -
trunk/scripts/TagInfoExtract.java
r14635 r14638 407 407 * @return the URL 408 408 */ 409 String createImage(StyleElement elem _style, final String type, NavigatableComponent nc) {409 String createImage(StyleElement element, final String type, NavigatableComponent nc) { 410 410 BufferedImage img = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); 411 411 Graphics2D g = img.createGraphics(); … … 413 413 StyledMapRenderer renderer = new StyledMapRenderer(g, nc, false); 414 414 renderer.getSettings(false); 415 elem _style.paintPrimitive(osm, MapPaintSettings.INSTANCE, renderer, false, false, false);415 element.paintPrimitive(osm, MapPaintSettings.INSTANCE, renderer, false, false, false); 416 416 final String imageName = type + "_" + tag + ".png"; 417 417 try (OutputStream out = Files.newOutputStream(options.imageDir.resolve(imageName))) { -
trunk/tools/pmd/josm-ruleset.xml
r14604 r14638 64 64 <exclude name="MethodArgumentCouldBeFinal"/> 65 65 <exclude name="MethodNamingConventions"/> 66 <exclude name="NoPackage"/> 66 67 <exclude name="OnlyOneReturn"/> 67 68 <exclude name="PrematureDeclaration"/>
Note:
See TracChangeset
for help on using the changeset viewer.