Java Code Examples for com.nextgis.maplib.util.NetworkUtil#get()
The following examples show how to use
com.nextgis.maplib.util.NetworkUtil#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LayerWithStyles.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
public void fillExtent() { try { mExtent = new GeoEnvelope(); String url = NGWUtil.getExtent(mConnection.getURL(), mRemoteId); HttpResponse response = NetworkUtil.get(url, mConnection.getLogin(), mConnection.getPassword(), false); if (!response.isOk()) return; JSONObject extent = new JSONObject(response.getResponseBody()).getJSONObject(JSON_EXTENT_KEY); double x = Geo.wgs84ToMercatorSphereX(extent.getDouble(JSON_MAX_LON_KEY)); double y = Geo.wgs84ToMercatorSphereY(extent.getDouble(JSON_MAX_LAT_KEY)); mExtent.setMax(x, y); x = Geo.wgs84ToMercatorSphereX(extent.getDouble(JSON_MIN_LON_KEY)); y = Geo.wgs84ToMercatorSphereY(extent.getDouble(JSON_MIN_LAT_KEY)); mExtent.setMin(x, y); } catch (IOException | JSONException ignored) { } }
Example 2
Source File: NGWLookupTable.java From android_maplib with GNU Lesser General Public License v3.0 | 6 votes |
protected void fillFromNGW(Map<String, String> dataMap, IProgressor progressor) throws IOException, NGException, JSONException { if (!mNet.isNetworkAvailable()) { //return tile from cache throw new NGException(getContext().getString(R.string.error_network_unavailable)); } if(null != progressor){ progressor.setMessage(getContext().getString(R.string.message_loading)); } Log.d(Constants.TAG, "download layer " + getName()); HttpResponse response = NetworkUtil.get(NGWUtil.getResourceUrl(mCacheUrl, mRemoteId), mCacheLogin, mCachePassword, false); if (!response.isOk()) { throw new NGException(NetworkUtil.getError(mContext, response.getResponseCode())); } JSONObject geoJSONObject = new JSONObject(response.getResponseBody()); JSONObject lookupTable = geoJSONObject.getJSONObject("lookup_table"); JSONObject itemsObject = lookupTable.getJSONObject("items"); for (Iterator<String> iter = itemsObject.keys(); iter.hasNext(); ) { String key = iter.next(); String value = itemsObject.getString(key); dataMap.put(key, value); } }
Example 3
Source File: CreateFromQMSLayerDialog.java From android_maplibui with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected HttpResponse doInBackground(Integer... params) { if (!mNet.isNetworkAvailable()) return new HttpResponse(NetworkUtil.ERROR_NETWORK_UNAVAILABLE); try { mLayerId = params[0]; return NetworkUtil.get(QMS_GEOSERVICE_URL + mLayerId + QMS_DETAIL_APPENDIX, null, null, false); } catch (IOException e) { e.printStackTrace(); } return new HttpResponse(NetworkUtil.ERROR_DOWNLOAD_DATA); }
Example 4
Source File: CreateFromQMSLayerDialog.java From android_maplibui with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected HttpResponse doInBackground(Void... params) { if (!mNet.isNetworkAvailable()) return new HttpResponse(NetworkUtil.ERROR_NETWORK_UNAVAILABLE); try { return NetworkUtil.get(QMS_GEOSERVICE_LIST_URL, null, null, false); } catch (IOException e) { e.printStackTrace(); } return new HttpResponse(NetworkUtil.ERROR_DOWNLOAD_DATA); }
Example 5
Source File: Connection.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
protected void fillCapabilities() { mSupportedTypes.clear(); try { String sURL = mURL + "/resource/schema"; HttpResponse response = NetworkUtil.get(sURL, getLogin(), getPassword(), false); if (!response.isOk()) return; JSONObject schema = new JSONObject(response.getResponseBody()); JSONObject resources = schema.getJSONObject("resources"); if (null != resources) { Iterator<String> keys = resources.keys(); while (keys.hasNext()) { int type = getType(keys.next()); if (type != NGWResourceTypeNone) { if (mSupportedTypes.isEmpty()) { mSupportedTypes.add(type); } else if (!isTypeSupported(type)) { mSupportedTypes.add(type); } } } } } catch (IOException | JSONException e) { e.printStackTrace(); } }
Example 6
Source File: Resource.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
public void fillPermissions() { try { String sURL = NGWUtil.getResourceUrl(mConnection.getURL(), mRemoteId) + "/permission"; HttpResponse response = NetworkUtil.get(sURL, mConnection.getLogin(), mConnection.getPassword(), false); if (!response.isOk()) return; mPermissions = new JSONObject(response.getResponseBody()); if (!mPermissions.has(Constants.JSON_RESOURCE_KEY)) mPermissions = null; } catch (IOException | JSONException e) { e.printStackTrace(); } }
Example 7
Source File: NGWRasterLayer.java From android_maplib with GNU Lesser General Public License v3.0 | 5 votes |
@Override public Bitmap getBitmap(TileItem tile) { if (!mExtentReceived) { HttpResponse result = null; try { AccountUtil.AccountData accountData = AccountUtil.getAccountData(mContext, getAccountName()); result = NetworkUtil.get(NGWUtil.getExtent(accountData.url, mRemoteId), getLogin(), getPassword(), false); if (!result.isOk()) { throw new IllegalStateException(""); } JSONObject extent = new JSONObject(result.getResponseBody()).getJSONObject(JSON_EXTENT_KEY); double x = Geo.wgs84ToMercatorSphereX(extent.getDouble(JSON_MAX_LON_KEY)); double y = Geo.wgs84ToMercatorSphereY(extent.getDouble(JSON_MAX_LAT_KEY)); mExtents.setMax(x, y); x = Geo.wgs84ToMercatorSphereX(extent.getDouble(JSON_MIN_LON_KEY)); y = Geo.wgs84ToMercatorSphereY(extent.getDouble(JSON_MIN_LAT_KEY)); mExtents.setMin(x, y); mExtentReceived = true; } catch (IOException | JSONException | IllegalStateException ignored) { if (result != null && result.getResponseCode() == 404) mExtentReceived = true; } } if (mExtents.intersects(tile.getEnvelope())) return super.getBitmap(tile); return null; }
Example 8
Source File: SettingsFragment.java From android_gisapp with GNU General Public License v3.0 | 5 votes |
@Override protected Boolean doInBackground(Void... voids) { try { String url = String.format("%s/%s/registered", URL, getUid(mPreference.getContext())); HttpResponse response = NetworkUtil.get(url, null, null, false); String body = response.getResponseBody(); JSONObject json = new JSONObject(body == null ? "" : body); return json.optBoolean("registered"); } catch (IOException | JSONException e) { return null; } }