Skip to content

Added UTM zone getter and UTM zone to getPROJ4Desription #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,15 @@ public void setUTMZone(int zone) {
initialize();
}

/**
*
* @return -1 if not UTM
*/
public int getUTMZone()
{
return utmZone;
}

public ProjCoordinate project(double lplam, double lpphi, ProjCoordinate xy) {
if (spherical) {
double cosphi = Math.cos(lpphi);
Expand Down Expand Up @@ -203,4 +212,41 @@ public String toString() {
return "Transverse Mercator";
}

/**
* Overrides method in Projection to output specific UTM PROJ.4 string
*
* @return
*/
@Override
public String getPROJ4Description()
{
if(utmZone >= 0)
{
StringBuffer sb = new StringBuffer();
sb.append("+proj=utm");

sb.append(" +zone=" + utmZone);

if(isSouth)
sb.append(" +south");

sb.append(" +a="+a);
if ( es != 0 )
sb.append( " +es="+es );
else
{
// When using a custom, spherical ellipsoid the previous behavior of
// this method was to output neither +b nor +es, which caused the
// Proj4Parser to default to the WGS84 ellipsoid. The simplest solution
// to this problem is to include +b in this string.
sb.append(" +b="+a);
}

return sb.toString();
}
else
{
return super.getPROJ4Description();
}
}
}