Commit 842a7db4 authored by André Starosta's avatar André Starosta
Browse files

Merge branch 'Modelagem' into 'develop'

Adicionado as classes Tile e PointD

See merge request !2
parents 64054b0d 7772cbcb
package ufpr.inf.pet.geoloc;
/**
* Created by pet on 20/05/15.
*/
public class PointD {
private double x;
private double y;
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("(").append(x).append(",").append(y).append(")");
return sb.toString();
}
}
package ufpr.inf.pet.geoloc;
import android.graphics.Bitmap;
/**
* Created by pet on 20/05/15.
*/
public class Tile {
private int x;
private int y;
private Bitmap img;
public int getX() {
return x;
}
public void setX(int x) {
this.x = x;
}
public int getY() {
return y;
}
public void setY(int y) {
this.y = y;
}
public Bitmap getImg() {
return img;
}
public void setImg(Bitmap img) {
this.img = img;
}
}
package ufpr.inf.pet.geoloc;
/**
* Created by vmocelin on 27/05/15.
*/
public class TilesManager {
private static double raioTerra = 6378137;
private double minLatitude;
private double maxLatitude;
private double minLongitude;
private double maxLongitude;
private int maxZoom = 5;
private int tamTile = 256;
private int viewWidth;
private int viewHeight;
private int tilesX;
private int tilesY;
private int zoom = 0;
private PointD location = new PointD();
private static double clip(double n, double minValue, double maxValue)
{
return Math.min(Math.max(n, minValue), maxValue);
}
public int tamanhoMapa(){
return (int) 256 << zoom;
}
public PointD longLatToXY(double latitude, double longitude){
latitude = clip(latitude, minLatitude, maxLatitude);
longitude = clip(longitude, minLongitude, maxLongitude);
double x = (longitude + 180) / 360;
double sinLatitude = Math.sin(latitude * Math.PI / 180);
double y = 0.5 - Math.log((1 + sinLatitude) / (1 - sinLatitude)) / (4 * Math.PI);
int mapSize = tamanhoMapa();
PointD pointD = new PointD();
pointD.setX((int) clip(x * mapSize + 0.5, 0, mapSize - 1));
pointD.setY((int) clip(y * mapSize + 0.5, 0, mapSize - 1));
return pointD;
}
public PointD xyToLongLat(int pixelX, int pixelY) {
double mapSize = tamanhoMapa();
double x = (clip(pixelX, 0, mapSize - 1) / mapSize) - 0.5;
double y = 0.5 - (clip(pixelY, 0, mapSize - 1) / mapSize);
PointD pointD = new PointD();
pointD.setX(90 - 360 * Math.atan(Math.exp(-y * 2 * Math.PI)) / Math.PI);
pointD.setY(360 * x);
return pointD;
}
public double getMinLatitude() {
return minLatitude;
}
public void setMinLatitude(double minLatitude) {
this.minLatitude = minLatitude;
}
public double getMaxLatitude() {
return maxLatitude;
}
public void setMaxLatitude(double maxLatitude) {
this.maxLatitude = maxLatitude;
}
public double getMinLongitude() {
return minLongitude;
}
public void setMinLongitude(double minLongitude) {
this.minLongitude = minLongitude;
}
public double getMaxLongitude() {
return maxLongitude;
}
public void setMaxLongitude(double maxLongitude) {
this.maxLongitude = maxLongitude;
}
public int getMaxZoom() {
return maxZoom;
}
public void setMaxZoom(int maxZoom) {
this.maxZoom = maxZoom;
}
public int getTamTile() {
return tamTile;
}
public void setTamTile(int tamTile) {
this.tamTile = tamTile;
}
public int getViewWidth() {
return viewWidth;
}
public void setViewWidth(int viewWidth) {
this.viewWidth = viewWidth;
}
public int getViewHeight() {
return viewHeight;
}
public void setViewHeight(int viewHeight) {
this.viewHeight = viewHeight;
}
public int getTilesX() {
return tilesX;
}
public void setTilesX(int tilesX) {
this.tilesX = tilesX;
}
public int getTilesY() {
return tilesY;
}
public void setTilesY(int tilesY) {
this.tilesY = tilesY;
}
public int getZoom() {
return zoom;
}
public void setZoom(int zoom) {
this.zoom = zoom;
}
public PointD getLocation() {
return location;
}
public void setLocation(PointD location) {
this.location = location;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment