public MapConverter(string mappath, string[] maptypen, GeoPunkt gplinksunten, GeoPunkt gprechtsoben, int gpauflösung, GeoPunkt mittelpunkt, int rasterdichte) { auflösung = gpauflösung; OSM_Koordinaten rechtsoben = new OSM_Koordinaten(gprechtsoben, auflösung); rechtsoben.BerechneOSMKachel(); OSM_Koordinaten linksunten = new OSM_Koordinaten(gplinksunten, auflösung); linksunten.BerechneOSMKachel(); minLat = rechtsoben.Osmbreite; maxLat = linksunten.Osmbreite; minLon = linksunten.Osmlänge; maxLon = rechtsoben.Osmlänge; dimLat = maxLat - minLat + 1; dimLon = maxLon - minLon + 1; if (dimLon < 1) { dimLon += rechtsoben.kachelanzahl; } readers = null; readers = new MapReader[dimLat][]; double osmpunkte = 256 / (40030 / Math.Pow(2, auflösung) * Math.Cos(mittelpunkt.Lat / 180 * Math.PI)); bildbreite = 256 * rasterdichte / (int)osmpunkte; bildhöhe = 256 * rasterdichte / (int)osmpunkte; for (int i = 0; i < readers.Length; i++) { readers[i] = new MapReader[dimLon]; for (int j = 0; j < readers[i].Length; j++) { int templon = minLon + j; if (templon >= rechtsoben.kachelanzahl) { templon -= rechtsoben.kachelanzahl; } readers[i][j] = new MapReader(minLat + i, templon, mappath, maptypen, auflösung, bildhöhe, bildbreite); //readers[i][j].PrepRead(); } } }
public Color GibFarbe(GeoPunkt geoPunkt) { Color color = Color.White; OSM_Koordinaten oSM_Koordinaten = new OSM_Koordinaten(geoPunkt, auflösung); oSM_Koordinaten.BerechneOSMKachel(); int maxLontemp = maxLon; if (maxLon < maxLat) { maxLontemp += oSM_Koordinaten.kachelanzahl; } if (oSM_Koordinaten.Osmbreite >= minLat && oSM_Koordinaten.Osmbreite <= maxLat && oSM_Koordinaten.Osmlänge >= minLon && oSM_Koordinaten.Osmlänge <= maxLontemp) { MapReader rdr = readers[oSM_Koordinaten.Osmbreite - minLat][oSM_Koordinaten.Osmlänge - minLon]; if (rdr.read == false) { rdr.PrepRead(); } color = rdr.Farbe((int)(rdr.BildHöhe * oSM_Koordinaten.Kachell), (int)(rdr.BildBreite * oSM_Koordinaten.Kachelb)); } return(color); }
/** * Class to extract elevation information from SRTM files in hgt format. * @param path a comma separated list of directories which may contain *.hgt files. * @param bbox the bounding box of the tile for which the DEM information is needed. * @param demPolygonMapUnits optional bounding polygon which describes the area for * which elevation should be read from hgt files. * @param interpolationMethod */ public HGTConverter(string hgtpath, string[] directorys, GeoPunkt linksunten, GeoPunkt rechtsoben) { // make bigger box for interpolation or aligning of areas int minLat = (int)Math.Floor(linksunten.Lat); int minLon = (int)Math.Floor(linksunten.Lon); int maxLat = (int)Math.Ceiling(rechtsoben.Lat); int maxLon = (int)Math.Ceiling(rechtsoben.Lon); eleArray = new double[4][]; for (int i = 0; i < eleArray.Length; i++) { eleArray[i] = new double[4]; } if (minLat < -90) { minLat = -90; } if (maxLat > 90) { maxLat = 90; } if (minLon < -180) { minLon += 360; } if (maxLon > 180) { maxLon -= 360; } if (minLon > maxLon) { maxLon += 360; } minLat32 = ToMapUnit(minLat) * 256; minLon32 = ToMapUnit(minLon) * 256; // create matrix of readers int dimLat = maxLat - minLat; int dimLon = maxLon - minLon; readers = new HGTReader[dimLat][]; for (int i = 0; i < dimLat; i++) { readers[i] = new HGTReader[dimLon]; } //demArea = demPolygonMapUnits; int maxRes = -1; for (int row = 0; row < dimLat; row++) { int lat = row + minLat; for (int col = 0; col < dimLon; col++) { int lon = col + minLon; //Area rdrBbox = new Area(lat, lon, lat + 1.0, lon + 1.0); //int testMode = intersectsPoly(rdrBbox); //if (testMode != 0) //{ HGTReader rdr = new HGTReader(lat, lon, hgtpath, directorys); readers[row][col] = rdr; maxRes = Math.Max(maxRes, rdr.GetRes()); //} } } res = maxRes; // we use the highest available res return; }
/** * Return elevation in meter for a point given in DEM units (32 bit res). * @param lat32 * @param lon32 * @return height in m or Short.MIN_VALUE if value is invalid */ public double GetHoehe(GeoPunkt geoPunkt) { return(GetElevation(ToMapUnit(geoPunkt.Lat) * 256, ToMapUnit(geoPunkt.Lon) * 256)); }
public void BerechneOSMKachel(GeoPunkt geoPunkt, int osmauflösung) { this.geoPunkt = geoPunkt; BerechneOSMKachel(osmauflösung); }
public OSM_Koordinaten(GeoPunkt geoPunkt, int osmauflösung) : this(geoPunkt) { Osmauflösung = osmauflösung; kachelanzahl = (int)Math.Pow(2, Osmauflösung); }
public OSM_Koordinaten(GeoPunkt geoPunkt) { this.geoPunkt = geoPunkt; }
public static double BestimmeAbstand(GeoPunkt p1, GeoPunkt p2) { double skalarprodukt = p1.Xgeo * p2.Xgeo + p1.Ygeo * p2.Ygeo + p1.Zgeo * p2.Zgeo; return(radius * Math.Acos(skalarprodukt / (radius * radius))); }