Changeset 32907 in osm for applications/editors/josm/plugins/seachart/jrender/src
- Timestamp:
- 2016-09-03T16:43:42+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/seachart/jrender/src/jrender/Jrender.java
r32906 r32907 1 /* Copyright 2014 Malcolm Herring 2 * 3 * This is free software: you can redistribute it and/or modify 4 * it under the terms of the GNU General Public License as published by 5 * the Free Software Foundation, version 3 of the License. 6 * 7 * For a copy of the GNU General Public License, see <http://www.gnu.org/licenses/>. 8 */ 9 1 // License: GPL. For details, see LICENSE file. 10 2 package jrender; 11 3 … … 27 19 import javax.imageio.ImageIO; 28 20 21 import render.ChartContext; 22 import render.Renderer; 29 23 import s57.S57map; 24 import s57.S57map.Feature; 25 import s57.S57map.Snode; 30 26 import s57.S57osm; 31 import s57.S57map.*;32 import render.*;33 27 34 public class Jrender { 28 /** 29 * @author Malcolm Herring 30 */ 31 public final class Jrender { 32 private Jrender() { 33 // Hide default constructor for utilities classes 34 } 35 35 36 36 static String srcdir; … … 46 46 47 47 static class Context implements ChartContext { 48 49 static double top; 50 static double mile; 51 52 public Context () { 53 top = (1.0 - Math.log(Math.tan(map.bounds.maxlat) + 1.0 / Math.cos(map.bounds.maxlat)) / Math.PI) / 2.0 * 256.0 * 4096.0 * Math.pow(2, (zoom - 12)); 54 mile = (2 * ((zoom < 12) ? (256 / (int)(Math.pow(2, (11 - zoom)))) : 256) + 256) / ((Math.toDegrees(map.bounds.maxlat) - Math.toDegrees(map.bounds.minlat)) * 60); 55 } 56 48 49 static double top; 50 static double mile; 51 52 Context() { 53 top = (1.0 - Math.log(Math.tan(map.bounds.maxlat) + 1.0 / Math.cos(map.bounds.maxlat)) / Math.PI) 54 / 2.0 * 256.0 * 4096.0 * Math.pow(2, (zoom - 12)); 55 mile = (2 * ((zoom < 12) ? (256 / (int) (Math.pow(2, (11 - zoom)))) : 256) + 256) 56 / ((Math.toDegrees(map.bounds.maxlat) - Math.toDegrees(map.bounds.minlat)) * 60); 57 } 58 59 @Override 57 60 public Point2D getPoint(Snode coord) { 58 61 double x = (Math.toDegrees(coord.lon) - Math.toDegrees(map.bounds.minlon)) * 256.0 * 2048.0 * Math.pow(2, (zoom - 12)) / 180.0; 59 double y = ((1.0 - Math.log(Math.tan(coord.lat) + 1.0 / Math.cos(coord.lat)) / Math.PI) / 2.0 * 256.0 * 4096.0 * Math.pow(2, (zoom - 12))) - top; 62 double y = ((1.0 - Math.log(Math.tan(coord.lat) + 1.0 / Math.cos(coord.lat)) / Math.PI) 63 / 2.0 * 256.0 * 4096.0 * Math.pow(2, (zoom - 12))) - top; 60 64 return new Point2D.Double(x, y); 61 65 } 62 66 67 @Override 63 68 public double mile(Feature feature) { 64 69 return mile; 65 70 } 66 71 72 @Override 67 73 public boolean clip() { 68 74 return false; 69 75 } 70 76 77 @Override 71 78 public Color background(S57map map) { 72 79 return new Color(0, true); 73 80 } 74 81 82 @Override 75 83 public RuleSet ruleset() { 76 84 return RuleSet.SEAMARK; 77 85 } 78 86 } 79 87 80 88 static void tile(int z, int s, int xn, int yn) throws IOException { 81 int border = (z < 12) ? (256 / (int)(Math.pow(2, (11 - zoom)))) : 256; 82 int scale = (int)Math.pow(2, z - 12); 89 int border = (z < 12) ? (256 / (int) (Math.pow(2, (11 - zoom)))) : 256; 90 int scale = (int) Math.pow(2, z - 12); 83 91 int xdir = (scale > 0) ? (scale * xtile) + xn : xtile; 84 92 int ynam = (scale > 0) ? (scale * ytile) + yn : ytile; … … 116 124 } 117 125 } 118 126 119 127 static void clean(int z, int xn, int yn) throws Exception { 120 128 int scale = (int) Math.pow(2, z - 12); … … 135 143 } 136 144 } 137 145 138 146 public static void main(String[] args) throws Exception { 139 147 if (args.length < 5) {
Note:
See TracChangeset
for help on using the changeset viewer.