本文整理汇总了Java中com.nextgis.maplib.util.NetworkUtil.get方法的典型用法代码示例。如果您正苦于以下问题:Java NetworkUtil.get方法的具体用法?Java NetworkUtil.get怎么用?Java NetworkUtil.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.nextgis.maplib.util.NetworkUtil
的用法示例。
在下文中一共展示了NetworkUtil.get方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fillExtent
import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
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) { }
}
示例2: fillFromNGW
import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
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.getResourceMetaUrl(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);
}
}
示例3: doInBackground
import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
@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);
}
示例4: fillCapabilities
import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
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();
}
}
示例5: fillStyles
import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
public void fillStyles()
{
mStyles = new ArrayList<>();
try {
String sURL = mConnection.getURL() + "/resource/" + mRemoteId + "/child/";
HttpResponse response =
NetworkUtil.get(sURL, mConnection.getLogin(), mConnection.getPassword(), false);
if (!response.isOk())
return;
JSONArray children = new JSONArray(response.getResponseBody());
for (int i = 0; i < children.length(); i++) {
//Only store style id
//To get more style properties need to create style class extended from Resource
//Style extends Resource
//mStyles.add(new Style(styleObject, mConnection);
JSONObject styleObject = children.getJSONObject(i);
JSONObject JSONResource = styleObject.getJSONObject("resource");
JSONArray interfaces = JSONResource.getJSONArray("interfaces");
for (int j = 0; j < interfaces.length(); j++) {
if (interfaces.getString(j).equals("IRenderableStyle")) {
long remoteId = JSONResource.getLong("id");
mStyles.add(remoteId);
break;
}
}
}
} catch (IOException | JSONException e) {
e.printStackTrace();
}
}
示例6: fillPermissions
import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
public void fillPermissions()
{
try {
String sURL = mConnection.getURL() + "/api/resource/" + 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();
}
}
示例7: getBitmap
import com.nextgis.maplib.util.NetworkUtil; //导入方法依赖的package包/类
@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;
}