public QueryLocations( Coordinates southwestCorner, Coordinates northeastCorner ) { locationsToQuery = new List<Coordinates[]>(); AddLocationBoundingBox( southwestCorner, northeastCorner ); }
public bool AddLocationBoundingBox( Coordinates southwestCorner, Coordinates northeastCorner ) { // Check is a valid box if ( northeastCorner.lng <= southwestCorner.lng ) return false; if ( northeastCorner.lat <= southwestCorner.lat ) return false; locationsToQuery.Add ( new Coordinates[]{ southwestCorner, northeastCorner } ); return true; }
// extract coords from location object public static Coordinates[] GetLocationData( JSONObject locationObj ) { try { if ( locationObj.HasProperty( "coordinates" ) ) { List<JSONObject> coords = locationObj.GetProperty ( "coordinates" ).props; if ( coords.Count % 2 != 0 ) throw new System.Exception( "Wrong coordinate setup?" ); Coordinates[] toRet = new Coordinates[ coords.Count / 2 ]; for ( int i = 0; i < coords.Count; i += 2 ) { toRet[i] = new Coordinates( (float)coords[i+1].n, (float)coords[i].n ); } return toRet; } throw new System.Exception( "wrong geo type" ); } catch ( System.Exception e ) { Console.WriteLine( "Location error:" + e.Message ); return new Coordinates[2]; } }