当前位置: 首页>>代码示例>>Java>>正文


Java PolyUtil类代码示例

本文整理汇总了Java中com.google.maps.android.PolyUtil的典型用法代码示例。如果您正苦于以下问题:Java PolyUtil类的具体用法?Java PolyUtil怎么用?Java PolyUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PolyUtil类属于com.google.maps.android包,在下文中一共展示了PolyUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: combineHoles

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
private static ArrayList<ArrayList<LatLng>> combineHoles(ArrayList<ArrayList<LatLng>> holes) {
    // Loop from last element
    // Each loop checks it against all other elements
    for (int i = (holes.size() - 1); i > 0; i--) {
        // loop from first element and combine checked element from above loop
        for (int j = 0 ; j < i ; j ++) {
            // Check to see if any point in j falls within i
            for (LatLng latLng : holes.get(i)) {
                // If it does, combine i to j and delete i
                if (PolyUtil.containsLocation(latLng, holes.get(j), true)) {
                    holes.set(j, combinePolygonGreen(holes.get(j), holes.get(i), true));
                    holes.remove(i);
                    // Recursivly run algorithm until no holes intersect
                    return combineHoles(holes);
                }
            }
        }
    }
    return holes;
}
 
开发者ID:kav0rka,项目名称:VennTracker,代码行数:21,代码来源:Circles.java

示例2: getLastIndex

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
private static int getLastIndex(ArrayList<LatLng> circlePoints, ArrayList<LatLng> checkAgainst) {
    int endIndex = 0;
    boolean stopChecking = false;
    for (LatLng latLng : circlePoints) {

        if (!PolyUtil.containsLocation(latLng, checkAgainst, isGeoDisc)) {
            endIndex = circlePoints.indexOf(latLng);
            stopChecking = true;
        } else {
            if (stopChecking) {
                break;
            }
        }
    }
    return endIndex;
}
 
开发者ID:kav0rka,项目名称:VennTracker,代码行数:17,代码来源:Circles.java

示例3: isPointOnPolygon

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
/**
 * Is the point of the polygon
 *
 * @param point     point
 * @param polygon   polygon
 * @param geodesic  geodesic check flag
 * @param tolerance distance tolerance
 * @return true if on the polygon
 */
public static boolean isPointOnPolygon(LatLng point, PolygonOptions polygon, boolean geodesic, double tolerance) {

    boolean onPolygon = PolyUtil.containsLocation(point, polygon.getPoints(), geodesic) ||
            PolyUtil.isLocationOnEdge(point, polygon.getPoints(), geodesic, tolerance);

    if (onPolygon) {
        for (List<LatLng> hole : polygon.getHoles()) {
            if (PolyUtil.containsLocation(point, hole, geodesic)) {
                onPolygon = false;
                break;
            }
        }
    }

    return onPolygon;
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:26,代码来源:MapUtils.java

示例4: Step

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
public Step(JSONObject jsonObject) throws JSONException {
        start = new Location("");
        end = new Location("");

        start.setLongitude(jsonObject.getJSONObject("start_location").getDouble("lng"));
        start.setLatitude(jsonObject.getJSONObject("start_location").getDouble("lat"));
        end.setLongitude(jsonObject.getJSONObject("end_location").getDouble("lng"));
        end.setLatitude(jsonObject.getJSONObject("end_location").getDouble("lat"));
//        street = jsonObject.getJSONArray("streets").length() > 0 ? jsonObject.getJSONArray("streets").getString(0) : "";
//        turnType = jsonObject.getInt("turnType");
        maneuver = jsonObject.has("maneuver") ? jsonObject.getString("maneuver") : "";
        narrative = jsonObject.getString("html_instructions");
        distance = jsonObject.getJSONObject("distance").getLong("value");
        polyline = PolyUtil.decode(jsonObject.getJSONObject("polyline").getString("points"));

    }
 
开发者ID:snigle,项目名称:corsaire,代码行数:17,代码来源:Step.java

示例5: getCurrentPoint

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
public Step getCurrentPoint(Location location) {
    int size = itinerary.steps.size();
    Step first = itinerary.steps.get(0);
    Step last = itinerary.steps.get(size - 1);

    for (int i = size - 1; i >= current_id; i--) {
        Step point = itinerary.steps.get(i);
        if (PolyUtil.isLocationOnPath(new LatLng(location.getLatitude(), location.getLongitude()), point.polyline, false, 18)) {
            Log.i(TAG, "Proche prolyline : " + i);
            current_id = i;
            return point;
        }
    }

    boolean onTheLine = PolyUtil.isLocationOnPath(new LatLng(location.getLatitude(), location.getLongitude()), PolyUtil.decode(itinerary.polyline), false, 35);

    Calendar before = Calendar.getInstance();
    before.add(Calendar.SECOND,-20);
    if(!onTheLine && location.getAccuracy()<25 && (lastCalcul == null || lastCalcul.before(before))){
        lastCalcul = Calendar.getInstance();
        itineraryHelper.getItinerary(itinerary.name,new LatLng(location.getLatitude(),location.getLongitude()),itinerary.getDest());
    }
    Log.i(TAG, "Sortie de piste");
    return current;
}
 
开发者ID:snigle,项目名称:corsaire,代码行数:26,代码来源:NavigationService.java

示例6: onMapReady

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
@Override
public void onMapReady(GoogleMap googleMap) {
	MapsInitializer.initialize(getActivity()); // required for the CameraUpdateFactory to be initialized
	googleMap.clear();
	googleMap.setMyLocationEnabled(true);

	googleMap.addMarker(new MarkerOptions().position(fromLocation).title(fromTitle));
	googleMap.addMarker(new MarkerOptions().position(toLocation).title(toTitle));

	List<LatLng> route = PolyUtil.decode(encodedRoute);
	googleMap.addPolyline(new PolylineOptions().addAll(route).color(R.color.green));

	LatLngBounds bounds = new LatLngBounds.Builder()
			.include(fromLocation)
			.include(toLocation)
			.build();
	googleMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 100));
}
 
开发者ID:FauDroids,项目名称:TripWeather,代码行数:19,代码来源:MapFragment.java

示例7: onMapReady

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
@Override
public void onMapReady() {
    if (mGoogleMap == null) {
        mGoogleMap = mMapFragment.getMap();
        if (mGoogleMap != null) {
            // You are good to use the map =)
            final UiSettings uiSettings = mGoogleMap.getUiSettings();
            uiSettings.setCompassEnabled(false);
            uiSettings.setZoomControlsEnabled(false);

            // Draw the paths
            if (!mDrawing.getEncodedPolylines().isEmpty()) {
                final LatLngBounds.Builder boundsBuilder = new LatLngBounds.Builder();
                for (String encodedPath : mDrawing.getEncodedPolylines()) {
                    final List<LatLng> pathPoints = PolyUtil.decode(encodedPath);
                    mGoogleMap.addPolyline(mPathOptions).setPoints(pathPoints);
                    for (LatLng point : pathPoints) {
                        boundsBuilder.include(point);
                    }
                }
                animateCameraToBounds(boundsBuilder.build());
                mDrawingLength.setText(getString(R.string.activity_drawing_viewer_drawing_length, mDrawing.getLength()));
            }
        }
    }
}
 
开发者ID:tvbarthel,项目名称:SayItFromTheSky,代码行数:27,代码来源:DrawingViewerActivity.java

示例8: checkIntersection

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
private void checkIntersection(LatLng point)
{

    if (arrayLayers == null)
        return;
    for (Parcel parcel : arrayLayers)
    {
        if (BuildConfig.DEBUG) Log.d(TAG, "======= Checking polygons for parcel =======");
        for (GeoJsonPolygon polygon : parcel.polygons)
        {
            if (BuildConfig.DEBUG) Log.d(TAG, polygon.getCoordinates().toString());
            if (BuildConfig.DEBUG) Log.d(TAG, point.toString());

            if (PolyUtil.containsLocation(point, polygon.getCoordinates().get(0), true))
                setPolygonGreen(parcel.layer);
            else
                setPolygonGrey(parcel.layer);
        }
    }
}
 
开发者ID:ekylibre,项目名称:zero-android,代码行数:21,代码来源:MapsActivity.java

示例9: drawMarker

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
/**
 * The function check if users tap a point close 200m to the freeway
 * then drag a markerOptions
 * @param point which is users tap on the map
 */
private void drawMarker(LatLng point) {
    List<LatLng> drawnPoints = globalPoly.getPoints();
    if (PolyUtil.isLocationOnPath(point, drawnPoints, true, 200.0)) {
        if(firstMarker == null){
            firstMarker = mMap.addMarker(new MarkerOptions().position(point).
                    icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_GREEN)).
                    draggable(true).title("Start"));
            startPoint = firstMarker.getPosition();
        }
        else if(secondMarker == null ){
            secondMarker = mMap.addMarker(new MarkerOptions().position(point).
                    icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_RED)).
                    draggable(true).title("End"));
            endPoint = secondMarker.getPosition();
        }
    }
}
 
开发者ID:Routelandia,项目名称:routelandia-android,代码行数:23,代码来源:MapsActivity.java

示例10: parseRoutes

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
/**
 * Parses the route information JSON string into a list of routes.
 */
private List<Route> parseRoutes(String json) {
    List<Route> routes = new ArrayList<Route>();
    try {
        JSONObject jsonObject = new JSONObject(json);
        JSONArray jRoutes = jsonObject.getJSONArray("routes");

        int len = jRoutes.length();
        for (int i = 0; i < len; i++) {
            JSONObject jobj = jRoutes.getJSONObject(i);
            Route route = new Route();

            route.name = jobj.getString("Name");
            route.polyLine = jobj.getString("Polyline");
            route.polyLinePositions = PolyUtil.decode(route.polyLine);
            route.color = jobj.getString("Color");
            route.stopList = parseStops(jobj);
            routes.add(route);
        }
    } catch (JSONException e) {
        Log.d(logTag, "JSONException occurred when getting routes as an array!", e);
    }

    return routes;
}
 
开发者ID:cartermp,项目名称:WMB,代码行数:28,代码来源:RoutesTask.java

示例11: subtractHoles

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
private static ArrayList<LatLng> subtractHoles(ArrayList<LatLng> polygonPointsGreen, Context context) {
    for (int i = mHoles.size() - 1 ; i >= 0 ; i--) {
        for (LatLng latLng : polygonPointsGreen) {
            if (PolyUtil.containsLocation(latLng, mHoles.get(i), isGeoDisc)) {
                polygonPointsGreen = subtractCircle(polygonPointsGreen, mHoles.get(i), context);
                mHoles.remove(i);
                break;
            }
        }

    }
    return polygonPointsGreen;
}
 
开发者ID:kav0rka,项目名称:VennTracker,代码行数:14,代码来源:Circles.java

示例12: closePolygonRing

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
/**
 * Close the polygon ring (exterior or hole) points if needed
 *
 * @param points ring points
 * @since 1.3.2
 */
public void closePolygonRing(List<LatLng> points) {
    if (!PolyUtil.isClosedPolygon(points)) {
        LatLng first = points.get(0);
        points.add(new LatLng(first.latitude, first.longitude));
    }
}
 
开发者ID:ngageoint,项目名称:geopackage-android-map,代码行数:13,代码来源:GoogleMapShapeConverter.java

示例13: loadDirection

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
private void loadDirection() {
    currentSubscription = directionRepository.getDirectionToToilet(currentLocation, toilet).subscribe(routeResponse -> {
        List<LatLng> latLngs = PolyUtil.decode(routeResponse.getPoints());
        mapView.showDirection(latLngs, toilet);
    }, throwable -> {
        Timber.e(throwable, throwable.getMessage());
    });
}
 
开发者ID:lvanyal,项目名称:directly,代码行数:9,代码来源:MapPresenter.java

示例14: DirectionsTaskResponse

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
public DirectionsTaskResponse(JSONObject jsonObject) throws JSONException {
    JSONObject route = jsonObject.getJSONArray("routes").getJSONObject(0);
    JSONObject leg = route.getJSONArray("legs").getJSONObject(0);
    List<LatLng> polylinePoints =
            PolyUtil.decode(route.getJSONObject("overview_polyline").getString("points"));
    polylineOptions = new PolylineOptions().addAll(polylinePoints).width(5f).color(Color.RED);
    distanceString = leg.getJSONObject("distance").getString("text");
    distance = leg.getJSONObject("distance").getInt("value");
}
 
开发者ID:rasmussaks,项目名称:aken-ajalukku,代码行数:10,代码来源:DirectionsTaskResponse.java

示例15: updateView

import com.google.maps.android.PolyUtil; //导入依赖的package包/类
private void updateView() {
    Step step = mService.getCurrent();
    String maneuver = mService.getManeuver();
    ((LinearLayout) findViewById(R.id.direction_layout)).setContentDescription(getString(R.string.dans)+" "+mService.getDistance()+" mètres, "+Html.fromHtml(mService.getNarrative()).toString());
    ((TextView) findViewById(R.id.distance)).setText(mService.getDistance() + " m");
    ((TextView) findViewById(R.id.narrative)).setText(Html.fromHtml(mService.getNarrative()));
    if(step instanceof TransitStep){
        ((ImageView) findViewById(R.id.image_direction)).setImageResource(R.drawable.ic_directions_transit_white_48dp);
    }
    else if(maneuver.contains("right")){
        ((ImageView) findViewById(R.id.image_direction)).setImageResource(R.drawable.right_turn);
    }else if(maneuver.contains("left")){
        ((ImageView) findViewById(R.id.image_direction)).setImageResource(R.drawable.left_turn);
    }
    else{
        ((ImageView) findViewById(R.id.image_direction)).setImageResource(R.drawable.straight);
    }
    Location mLastLocation = mService.getLocation();
    if (mMap != null) {
        myPosition.setPosition(mService.getLatLng());
        if (centred && mLastLocation != null) {
            mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(mLastLocation.getLatitude(), mLastLocation.getLongitude()), DEFAULT_ZOOM));
        }
        if (polyline != null)
            polyline.remove();
            polyline = mMap.addPolyline(new PolylineOptions().addAll(PolyUtil.decode(mService.getItinerary().polyline)).color(getResources().getColor(R.color.colorAccent)));
    }

}
 
开发者ID:snigle,项目名称:corsaire,代码行数:30,代码来源:NavigationActivity.java


注:本文中的com.google.maps.android.PolyUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。