Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Geoloc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
PET Computação
Geoloc
Merge requests
!2
Adicionado as classes Tile e PointD
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Adicionado as classes Tile e PointD
Modelagem
into
develop
Overview
0
Commits
2
Changes
2
Merged
Davisson Henrique Paulino
requested to merge
Modelagem
into
develop
9 years ago
Overview
0
Commits
2
Changes
2
Expand
0
0
Merge request reports
Viewing commit
41f90126
Prev
Next
Show latest version
2 files
+
71
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
2
Search (e.g. *.vue) (Ctrl+P)
41f90126
Adicionado as classes Tile e PointD
· 41f90126
Davisson Henrique Paulino
authored
9 years ago
app/src/main/java/ufpr/inf/pet/geoloc/TilesManager.java
0 → 100644
+
151
−
0
Options
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;
}
}
Loading