KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I'm porting some geolocation java code from http://janmatuschek.de/LatitudeLongitudeBoundingCoordinates#Java (shown below) to python. It can be initialized using two functions (fromDegrees or fromRadians). I thought I could do something like class geoLocation: _radLat = 0 _radLong = 0 _degLat = 0 _degLong = 0 def fromDegrees(lat, long): #set _radLat, _radLong, _degLat, _degLong def fromRadians(lat, long): #set _radLat, _radLong, _degLat, _degLong ... But that does not seem optimal since I set the values for _radLat, _radLong, _degLat and _degLong twice. Can I define two init functions? What's the best way to do that? Thanks /** * <p>Represents a point on the surface of a sphere. (The Earth is almost * spherical.)</p> * * <p>To create an instance, call one of the static methods fromDegrees() or * fromRadians().</p> * * <p>This code was originally published at * <a href="http://JanMatuschek.de/LatitudeLongitudeBoundingCoordinates#Java"> * http://JanMatuschek.de/LatitudeLongitudeBoundingCoordinates#Java</a>.</p> * * @author Jan Philip Matuschek * @version 27 May 2010 */ public class GeoLocation { private double radLat; // latitude in radians private double radLon; // longitude in radians private double degLat; // latitude in degrees private double degLon; // longitude in degrees private static final double MIN_LAT = Math.toRadians(-90d); // -PI/2 private static final double MAX_LAT = Math.toRadians(90d); // PI/2 private static final double MIN_LON = Math.toRadians(-180d); // -PI*2 private static final double MAX_LON = Math.toRadians(180d); // PI*2 private GeoLocation () { } /** * @param latitude the latitude, in degrees. * @param longitude
Tags (comma-separated)
Save Edits
Cancel