-
Notifications
You must be signed in to change notification settings - Fork 2
/
insarmaps_query.py
executable file
·53 lines (40 loc) · 1.75 KB
/
insarmaps_query.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#! /usr/bin/env python2
############################################################
# Program is part of MintPy #
# Copyright (c) 2013, Zhang Yunjun, Heresh Fattahi #
# Author: Alfredo Terrero, 2016 #
############################################################
import urllib.request, urllib.error, urllib.parse
import argparse
class BasicHTTP:
@staticmethod
def get(url):
res = urllib.request.urlopen(url)
return res.read()
def buildURL(args):
url = "http://ec2-52-41-231-16.us-west-2.compute.amazonaws.com/WebServices?"
if args.dataset:
url += "dataset=" + args.dataset + "&"
if args.longitude:
url += "longitude=" + args.longitude + "&"
if args.latitude:
url += "latitude=" + args.latitude + "&"
return url[:-1]
def build_parser():
parser = argparse.ArgumentParser(description='Query insarmaps database.')
parser.add_argument("-s", "--satellite", help="satellite to search for")
parser.add_argument("-r", "--relativeOrbit", help="relative orbit to search for")
parser.add_argument("-f", "--firstFrame", help="first frame to search for")
parser.add_argument("-m", "--mode", help="mode to search for")
parser.add_argument("-d", "--flightDir", help="flight direction to search for")
parser.add_argument("-D", "--dataset", help="dataset to search in")
parser.add_argument("-l", "--latitude", help="latitude of point to search for")
parser.add_argument("-L", "--longitude", help="longitude of point to search for")
return parser
def main():
parser = build_parser()
parseArgs = parser.parse_args()
url = buildURL(parseArgs)
print(BasicHTTP.get(url))
if __name__ == '__main__':
main()