# Gs Catalog and Importer
"""
    The following variables must contain a reachable and valid REST URL of the
    GeoServer where the mosaics have been configured.
    
    The GeoServer USERNAME and PASSWORD *are not* the ones configured on GeoNode.
    It is mandatory to create a GeoServer manager user (by default admin/geoserver)
    with WRITE (or ADMIN) rights and BASIC AUTH access enabled.
"""
url = "http://localhost:8080/geoserver/rest" # Notice that the URL *must* contain the '/rest' path
_user = "******" # BASIC AUTH enabled GeoServer USER with WRITE or ADMIN rights
_password = "******" 
# We are going to configure the GeoServer remote clients
gs_catalog = Catalog(url, _user, _password)
gs_uploader = Client(url, _user, _password)

# Input Variables
"""
    The following ones are the variables provided via the command line.
    
    e.g.:
    
    python mosaic_METOFFICE-GLO-SST-L4-NRT-OBS-SKIN-DIU.py METOFFICE-GLO-SST-L4-NRT-OBS-SKIN-DIU.nc temperature METOFFICE_GLO_SST_L4_NRT_OBS_SKIN_DIU
                                                           sys.argv[1]                              sys.argv[2] sys.argv[3] 
"""
file_nc = sys.argv[1]                                     # Filesystem path of the input NetCDF4 file e.g.: path_to_the_file/METOFFICE-GLO-SST-L4-NRT-OBS-SKIN-DIU.nc
vname = sys.argv[2]                                       # Name of the variable to extract e.g.: temperature
target_bbox = sys.argv[3] if len(sys.argv) > 3 else None  # Subset Area e.g.: -115.561581,-2.270676,-40.722711,36.750010
target_store = sys.argv[4] if len(sys.argv) > 4 else None # Name of the existing Mosaic in GeoServer e.g.: JPL_OUROCEAN-L4UHfnd-GLOB-v01-fv01_0-G1SST_temperature
示例#2
0
    def test_invalid_target(self):
        session = client.upload(vector_file('san_andres_y_providencia_poi.shp'))
        try:
            session.tasks[0].target.change_datastore('foobar')
            self.fail('Expected BadRequest')
        except BadRequest, br:
            self.assertEqual('Unable to find referenced store', str(br))
        except:
            self.fail('Expected BadRequest')


print 'using GEOSERVER_BASE_URL=%s' % GEOSERVER_BASE_URL

# Preflight connection testing
print 'testing access...',
client = Client(GEOSERVER_REST_URL)
gscat = catalog.Catalog(GEOSERVER_REST_URL)
try:
    sessions = client.get_sessions()
    print 'successfully listed imports...',
    ids = [ s.id for s in sessions ]
    gscat.get_layers()
    print 'successfully listed layers...'
except socket.error, ex:
    print 'error connecting to the server, check your GEOSERVER_BASE_URL'
    print ex
    sys.exit(1)

# handy while testing
if '--clean' in sys.argv:
    print 'cleaning'
示例#3
0
ogc_server_settings = OGC_Servers_Handler(settings.OGC_SERVER)['default']

_wms = None
_csw = None
_user, _password = ogc_server_settings.credentials

http_client = httplib2.Http()
http_client.add_credentials(_user, _password)
http_client.add_credentials(_user, _password)
_netloc = urlparse(ogc_server_settings.LOCATION).netloc
http_client.authorizations.append(
    httplib2.BasicAuthentication((_user, _password), _netloc,
                                 ogc_server_settings.LOCATION, {}, None, None,
                                 http_client))

url = ogc_server_settings.rest
gs_catalog = Catalog(url, _user, _password)
gs_uploader = Client(url, _user, _password)

_punc = re.compile(r"[\.:]")  #regex for punctuation that confuses restconfig
_foregrounds = [
    "#ffbbbb", "#bbffbb", "#bbbbff", "#ffffbb", "#bbffff", "#ffbbff"
]
_backgrounds = [
    "#880000", "#008800", "#000088", "#888800", "#008888", "#880088"
]
_marks = ["square", "circle", "cross", "x", "triangle"]
_style_contexts = izip(cycle(_foregrounds), cycle(_backgrounds), cycle(_marks))
_default_style_names = ["point", "line", "polygon", "raster"]