當前位置: 首頁>>代碼示例>>Java>>正文


Java MapUtil類代碼示例

本文整理匯總了Java中com.nextgis.maplib.util.MapUtil的典型用法代碼示例。如果您正苦於以下問題:Java MapUtil類的具體用法?Java MapUtil怎麽用?Java MapUtil使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MapUtil類屬於com.nextgis.maplib.util包,在下文中一共展示了MapUtil類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: zoomStop

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
protected void zoomStop()
{
    if (mDrawingState == DRAW_STATE_zooming && mMap != null) {

        float zoom = MapUtil.getZoomForScaleFactor(mScaleFactor, mMap.getZoomLevel());

        GeoEnvelope env = mMap.getFullScreenBounds();
        GeoPoint focusPt = new GeoPoint(-mCurrentFocusLocation.x, -mCurrentFocusLocation.y);

        double invertScale = 1 / mScaleFactor;

        double offX = (1 - invertScale) * focusPt.getX();
        double offY = (1 - invertScale) * focusPt.getY();
        env.scale(invertScale);
        env.offset(offX, offY);

        GeoPoint newCenterPt = env.getCenter();
        GeoPoint newCenterPtMap = mMap.screenToMap(newCenterPt);

        if(Constants.DEBUG_MODE) {
            Log.d(TAG, "zoomStop: setZoomAndCenter");
        }

        setZoomAndCenter(zoom, newCenterPtMap);
    }
}
 
開發者ID:nextgis,項目名稱:android_maplibui,代碼行數:27,代碼來源:MapView.java

示例2: doInBackground

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
@Override
protected Void doInBackground(File... path) {
    if (path.length > 0) {
        if (path[0].exists() && path[0].isDirectory()) {
            File[] data = path[0].listFiles();
            int c = 0;
            for (File file : data) {
                publishProgress(++c, data.length);
                if (file.isDirectory() && MapUtil.isParsable(file.getName()))
                    FileUtil.deleteRecursive(file);
            }
        }
    }

    return null;
}
 
開發者ID:nextgis,項目名稱:android_maplibui,代碼行數:17,代碼來源:ClearCacheTask.java

示例3: getTilesCount

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
private long getTilesCount(AsyncTask task, MapBase map, int leftThumbIndex, int rightThumbIndex) {
    TMSLayer layer = (TMSLayer) map.getLayerById(getLayerId());
    GeoEnvelope envelope = getEnvelope();
    long total = 0;
    for (int zoom = leftThumbIndex; zoom <= rightThumbIndex; zoom++) {
        if (task != null && task.isCancelled())
            return total;

        total += MapUtil.getTileCount(task, envelope, zoom, layer.getTMSType());
    }

    return total;
}
 
開發者ID:nextgis,項目名稱:android_maplibui,代碼行數:14,代碼來源:SelectZoomLevelsDialog.java

示例4: getTileItems

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
protected List<TileItem> getTileItems(
        GeoEnvelope bounds,
        double zoom,
        RemoteTMSLayer tmsLayer)
{
    return MapUtil.getTileItems(bounds, zoom, tmsLayer.getTMSType());
}
 
開發者ID:nextgis,項目名稱:android_maplibui,代碼行數:8,代碼來源:TileDownloadService.java

示例5: setZoomText

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
public static void setZoomText(
        Activity activity,
        TextView text,
        int string,
        int zoom)
{
    String scale = LocationUtil.formatLength(activity, MapUtil.getScaleInCm(activity, zoom), 0);
    text.setText(String.format(activity.getString(string) + "\r\n" + scale, zoom));
}
 
開發者ID:nextgis,項目名稱:android_maplibui,代碼行數:10,代碼來源:ControlHelper.java

示例6: zoomToExtent

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
public void zoomToExtent(GeoEnvelope envelope, float maxZoom) {
    if (envelope.isInit()) {
        double size = GeoConstants.MERCATOR_MAX * 2;
        double scale = Math.min(envelope.width() / size, envelope.height() / size);
        double zoom = MapUtil.lg(1 / scale);
        if (zoom < getMinZoom())
            zoom = getMinZoom();
        if (zoom > maxZoom)
            zoom = maxZoom;

        setZoomAndCenter((float) zoom, envelope.getCenter());
    }
}
 
開發者ID:nextgis,項目名稱:android_maplib,代碼行數:14,代碼來源:MapDrawable.java

示例7: bindView

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
private void bindView(int position, View view) {
    final Map dataSet = mFiltered.get(position);
    if (dataSet == null)
        return;

    final String[] from = mFrom;
    final int[] to = mTo;
    final int count = to.length;

    for (int i = 0; i < count; i++) {
        final View v = view.findViewById(to[i]);
        if (v != null) {
            final Object data = dataSet.get(from[i]);
            String text = data == null ? "" : data.toString();
            if (text == null)
                text = "";

            if (v instanceof Checkable) {
                if (v instanceof TextView) {
                    TextView textView = (TextView) v;
                    // Note: keep the instanceof TextView check at the bottom of these
                    // ifs since a lot of views are TextViews (e.g. CheckBoxes).
                    setViewText(textView, text);
                    setIcon(textView, null);

                    String id = (String) dataSet.get(KEY_ICON);
                    if (id == null || !MapUtil.isParsable(id))
                        id = "default";

                    File icon = new File(mQMSIconsDir, id);
                    if (icon.exists())
                        setIcon(textView, icon.getPath());
                    else if (mIconsQueue.keySet().contains(id))
                        mIconsQueue.get(id).addViewWithIcon(textView);
                    else {
                        LoadIcon task = new LoadIcon(icon.getPath(), textView);
                        mIconsQueue.put(id, task);
                        task.execute();
                    }
                }
            }
        }
    }
}
 
開發者ID:nextgis,項目名稱:android_maplibui,代碼行數:45,代碼來源:CreateFromQMSLayerDialog.java

示例8: createNewLocalTMSLayer

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
@Override
public void createNewLocalTMSLayer(
        final Context context,
        final LayerGroup groupLayer,
        final Uri uri)
{
    String ext = "zip";
    String layerName =
            FileUtil.getFileNameByUri(context, uri, context.getString(R.string.new_layer));
    final int lastPeriodPos = layerName.lastIndexOf('.');
    if (lastPeriodPos > 0) {
        ext = layerName.substring(lastPeriodPos).toLowerCase();
        layerName = layerName.substring(0, lastPeriodPos);
    }
    if (context instanceof NGActivity) {
        NGActivity fragmentActivity = (NGActivity) context;

        if (ext.equals(".ngrc")) {
            Intent intent = new Intent(context, LayerFillService.class);
            intent.setAction(LayerFillService.ACTION_ADD_TASK);
            intent.putExtra(LayerFillService.KEY_URI, uri);
            intent.putExtra(LayerFillService.KEY_INPUT_TYPE, LayerFillService.TMS_LAYER);
            intent.putExtra(LayerFillService.KEY_LAYER_GROUP_ID, groupLayer.getId());

            LayerFillProgressDialogFragment.startFill(intent);
            return;
        }

        AtomicReference<Uri> temp = new AtomicReference<>(uri);
        if (MapUtil.isZippedGeoJSON(context, temp)) {
            createNewVectorLayer(context, groupLayer, temp.get());
            return;
        }

        CreateLocalLayerDialog newFragment = new CreateLocalLayerDialog();
        newFragment.setLayerGroup(groupLayer)
                .setLayerType(LayerFillService.TMS_LAYER)
                .setUri(uri)
                .setLayerName(layerName)
                .setTitle(context.getString(R.string.create_tms_layer))
                .setTheme(fragmentActivity.getThemeId())
                .show(fragmentActivity.getSupportFragmentManager(), "create_tms_layer");
    }
}
 
開發者ID:nextgis,項目名稱:android_maplibui,代碼行數:45,代碼來源:LayerFactoryUI.java

示例9: getSelection

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
protected String getSelection() {
    return TrackLayer.FIELD_ID + " IN (" + MapUtil.makePlaceholders(mTracks.getSelectedItemsCount()) + ")";
}
 
開發者ID:nextgis,項目名稱:android_maplibui,代碼行數:4,代碼來源:TracksActivity.java

示例10: putAttaches

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
protected int putAttaches() {
    int total = 0;
    PhotoGallery gallery = (PhotoGallery) findViewById(R.id.pg_photos);

    if (gallery != null && mFeatureId != NOT_FOUND) {
        List<Integer> deletedAttaches = gallery.getDeletedAttaches();
        IGISApplication application = (IGISApplication) getApplication();
        Uri uri = Uri.parse("content://" + application.getAuthority() + "/" +
                mLayer.getPath().getName() + "/" + mFeatureId + "/" + Constants.URI_ATTACH);

        int size = deletedAttaches.size();
        String[] args = new String[size];
        for (int i = 0; i < size; i++)
            args[i] = deletedAttaches.get(i).toString();

        if (size > 0)
            total += getContentResolver().delete(uri, MapUtil.makePlaceholders(size), args);

        if (total == 0 && size > 0) {
            Toast.makeText(this, getText(R.string.photo_fail_attach), Toast.LENGTH_SHORT).show();
            Log.d(TAG, "attach delete failed");
        } else {
            Log.d(TAG, "attach delete success: " + total);
        }

        List<String> imagesPath =  gallery.getNewAttaches();
        for (String path : imagesPath) {
            String[] segments = path.split("/");
            String name = segments.length > 0 ? segments[segments.length - 1] : "image.jpg";
            ContentValues values = new ContentValues();
            values.put(VectorLayer.ATTACH_DISPLAY_NAME, name);
            values.put(VectorLayer.ATTACH_MIME_TYPE, "image/jpeg");

            Uri result = getContentResolver().insert(uri, values);
            if (result == null) {
                Toast.makeText(this, getText(R.string.photo_fail_attach), Toast.LENGTH_SHORT).show();
                Log.d(TAG, "attach insert failed");
            } else {
                if (copyToStream(result, path))
                    total++;

                Log.d(TAG, "attach insert success: " + result.toString());
            }
        }
    }

    return total;
}
 
開發者ID:nextgis,項目名稱:android_maplibui,代碼行數:49,代碼來源:ModifyAttributesActivity.java

示例11: doInBackground

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
@Override
protected Void doInBackground(Void... params) {
    while (!mIsChosen)
        SystemClock.sleep(500);

    if (mIsCanceled)
        return null;

    publishProgress();
    File temp = null, parent = MapUtil.prepareTempDir(mActivity, "exported_tracks");
    try {
        IGISApplication application = (IGISApplication) mActivity.getApplication();
        Uri mContentUriTracks = Uri.parse("content://" + application.getAuthority() + "/" + TrackLayer.TABLE_TRACKS);
        Cursor track, trackpoints;
        final StringBuilder sb = new StringBuilder();
        final Formatter f = new Formatter(sb);
        if (!mSeparateFiles) {
            temp = new File(parent, "tracks.gpx");
            FileUtil.writeToFile(temp, mHeader);
        }

        for (String trackId : mTracksId) {
            if (mIsCanceled)
                return null;

            track = mActivity.getContentResolver().query(mContentUriTracks,
                    new String[]{TrackLayer.FIELD_NAME}, TrackLayer.FIELD_ID + " = ?", new String[]{trackId}, null);
            trackpoints = mActivity.getContentResolver().query(Uri.withAppendedPath(mContentUriTracks,
                    trackId), null, null, null, TrackLayer.FIELD_TIMESTAMP + " ASC");

            if (track != null && track.moveToFirst()) {
                if (mSeparateFiles) {
                    temp = new File(parent, track.getString(0) + ".gpx");
                    FileUtil.writeToFile(temp, mHeader);
                }

                if (trackpoints != null && trackpoints.moveToFirst()) {
                    if (mSeparateFiles) {
                        appendTrack(temp, track.getString(0), sb, f, trackpoints);
                        FileUtil.writeToFile(temp, GPX_TAG_CLOSE, true);
                        mUris.add(Uri.fromFile(temp));
                    } else
                        appendTrack(temp, track.getString(0), sb, f, trackpoints);

                    trackpoints.close();
                } else
                    mNoPoints++;

                track.close();
            }
        }

        if (!mSeparateFiles) {
            FileUtil.writeToFile(temp, GPX_TAG_CLOSE, true);
            mUris.add(Uri.fromFile(temp));
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    return null;
}
 
開發者ID:nextgis,項目名稱:android_maplibui,代碼行數:63,代碼來源:LayerUtil.java

示例12: onPostExecute

import com.nextgis.maplib.util.MapUtil; //導入依賴的package包/類
@Override
protected void onPostExecute(String result) {
    super.onPostExecute(result);

    String message;
    if (!MapUtil.isParsable(result)) {
        try {
            JSONObject obj = new JSONObject(result);
            Long id = obj.getLong(Constants.JSON_ID_KEY);

            if (mLayer != null) {
                ((NGWVectorLayer) mLayer).setSyncType(Constants.SYNC_DATA);
                mLayer.save();
                mLayer.toNGW(id, mConnection.getName(), Constants.SYNC_DATA, mVer);
                mCounter--;

                if (mCounter == 0) {
                    mProgress.dismiss();
                    finish();
                }
            }

            result = null;
        } catch (JSONException e) {
            result = "500";
            e.printStackTrace();
        }
    }

    if (result != null) {
        switch (result) {
            case "-999":
                message = getString(R.string.btn_ok);
                break;
            default:
                message = NetworkUtil.getError(mContext, result);
                break;
        }

        Toast.makeText(mContext, message, Toast.LENGTH_LONG).show();
        mProgress.dismiss();
    }
}
 
開發者ID:nextgis,項目名稱:nextgislogger,代碼行數:44,代碼來源:NGWLoginActivity.java


注:本文中的com.nextgis.maplib.util.MapUtil類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。