• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java GeoLocation类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: onKeyEntered

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
/**
 * Parse location to fetch matching events
 * @param key the geoindex key
 * @param location the corresponding location
 */
@Override
public void onKeyEntered(String key, GeoLocation location) {
    String[] parts = key.split("@");
    String userId = parts[0];
    String eventId = parts[1];
    if(users.contains(userId)) {
        FirebaseDatabase.getInstance().getReference("events/"+userId+"/"+eventId).addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(DataSnapshot dataSnapshot) {
                HabitEventDataModel model = dataSnapshot.getValue(HabitEventDataModel.class);

                if (model != null) {
                    HabitEvent habitEvent = model.getHabitEvent();
                    nearbyEvents.add(habitEvent);
                    datasetChanged();
                }
            }

            @Override
            public void onCancelled(DatabaseError databaseError) {

            }
        });
    }
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:31,代码来源:NearbyHabitEventDataSource.java


示例2: filterByNearby

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
/**
 * Filter by habit events within 5km
 */
private void filterByNearby(final ArrayList<String> followingIds) {
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
            ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {

        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION},
                MY_PERMISSIONS_REQUEST_LOCATION);
        return;
    }

    mFusedLocationClient.getLastLocation()
            .addOnSuccessListener(this, new OnSuccessListener<Location>() {
                @Override
                public void onSuccess(Location location) {
                    // Got last known location. In some rare situations this can be null.

                    if (location != null) {
                        // Logic to handle location object
                        HabitHistoryActivity.this.location = location;
                        LatLng loc = new LatLng(location.getLatitude(), location.getLongitude());

                        eventDataSource = new NearbyHabitEventDataSource(new GeoLocation(loc.latitude, loc.longitude), followingIds);
                        eventDataSource.addObserver(HabitHistoryActivity.this);
                        eventDataSource.open();
                        habitEvents = eventDataSource.getSource();
                        habitHistoryAdapter = new HabitHistoryAdapter(HabitHistoryActivity.this, habitEvents);
                        habitsListView.setAdapter(habitHistoryAdapter);

                        // TODO: update the data source here with the list of friends
                    } else {
                        Toast.makeText(HabitHistoryActivity.this, "Error getting location",
                                Toast.LENGTH_LONG).show();
                    }
                }
            });
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:40,代码来源:HabitHistoryActivity.java


示例3: add

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
/**
 * Add a habit event to the database
 * It's location is geocoded into the events_geofire index
 * @param habitEvent the event to add
 */
@Override
public void add(HabitEvent habitEvent) {
    HabitEventDataModel eventModel = new HabitEventDataModel(habitEvent);

    DatabaseReference newEvent = mHabitEventsRef.push();
    eventModel.setKey(newEvent.getKey());

    // Reverse Chronological Order
    newEvent.setValue(eventModel, -1 * habitEvent.getEventDate().getMillis(), null);
    geoFire.setLocation(userId+'@'+newEvent.getKey(), new GeoLocation(habitEvent.getLatitude(), habitEvent.getLongitude()));
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:17,代码来源:HabitEventRepository.java


示例4: update

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
/**
 * Update data at existing index with data
 * @param key the event key
 * @param habitEvent the event object
 */
@Override
public void update(String key, HabitEvent habitEvent) {
    HabitEventDataModel eventModel = new HabitEventDataModel(habitEvent);
    mHabitEventsRef.child(key).getRef().setValue(eventModel, null);
    geoFire.setLocation(userId+'@'+habitEvent.getKey(), new GeoLocation(habitEvent.getLatitude(), habitEvent.getLongitude()));
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:12,代码来源:HabitEventRepository.java


示例5: animateFriendMarker

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
public void animateFriendMarker(String uid, GeoLocation location){
    final double lat = location.latitude;
    final double lng = location.longitude;
    final Handler handler = new Handler();
    final long start = SystemClock.uptimeMillis();
    final long DURATION_MS = 3000;
    final Interpolator interpolator = new AccelerateDecelerateInterpolator();
    final Marker marker = markerUserIdHashMap.get(uid);
    final LatLng startPosition = marker.getPosition();
    handler.post(new Runnable() {
        @Override
        public void run() {
            float elapsed = SystemClock.uptimeMillis() - start;
            float t = elapsed/DURATION_MS;
            float v = interpolator.getInterpolation(t);

            double currentLat = (lat - startPosition.latitude) * v + startPosition.latitude;
            double currentLng = (lng - startPosition.longitude) * v + startPosition.longitude;
            marker.setPosition(new LatLng(currentLat, currentLng));

            // if animation is not finished yet, repeat
            if (t < 1) {
                handler.postDelayed(this, 16);
            }
        }
    });
}
 
开发者ID:mremondi,项目名称:Hyke,代码行数:28,代码来源:NearMeFragment.java


示例6: saveToFirebase

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
public static void saveToFirebase(GeoFire geoFire,Firebase db, Tutor tutor, Location location){
    if(location != null) {
        Firebase tutorStore = db.child("tutors").child(tutor.getFullName());
        tutorStore.setValue(tutor);
        geoFire.setLocation(tutor.getFullName(), new GeoLocation(location.getLatitude(), location.getLongitude()));
    }
}
 
开发者ID:StephenVanSon,项目名称:TutorMe,代码行数:8,代码来源:Tutor.java


示例7: IndegoStation

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
public IndegoStation(String kioskId, GeoLocation location,double distance, String name, Integer bikesAvailable, Integer docksAvialable){
    this.kioskId = kioskId;
    this.location = location;
    this.bikesAvailable = bikesAvailable;
    this.docksAvialable = docksAvialable;
    this.distance = distance;
    this.name = name;

}
 
开发者ID:RobertTrebor,项目名称:CycleFrankfurtAndroid,代码行数:10,代码来源:IndegoStation.java


示例8: onCreate

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    Timber.tag(getClass().getSimpleName());
    Timber.d(getClass().getSimpleName() + " is creating");

    UserLocation currentLocation = CacheManager.pluck().getUserLocation();
    if (currentLocation == null) {
        currentLocation = new UserLocation();
        currentLocation.setLatitude(-7.76772);
        currentLocation.setLongitude(110.37863);
    }
    GeoLocation location = new GeoLocation(currentLocation.getLatitude(), currentLocation.getLongitude());

    GeoQuery query = FirebaseApi.pluck().userLocations().queryAtLocation(location, 20);

    CacheManager.pluck().listenUserLocation()
            .subscribe(userLocation -> {
                if (userLocation != null) {
                    GeoLocation newLocation = new GeoLocation(userLocation.getLatitude(),
                                                              userLocation.getLongitude());
                    query.setCenter(newLocation);
                }
            }, throwable -> {
                Timber.e(throwable.getMessage());
            });

    query.addGeoQueryEventListener(this);
}
 
开发者ID:zetbaitsu,项目名称:Sigap,代码行数:30,代码来源:NearbyService.java


示例9: onKeyEntered

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
@Override
public void onKeyEntered(String key, GeoLocation location) {
    UserLocation userLocation = new UserLocation();
    userLocation.setUserId(key);
    userLocation.setLatitude(location.latitude);
    userLocation.setLongitude(location.longitude);
    CacheManager.pluck().cacheNearbyUser(userLocation);
}
 
开发者ID:zetbaitsu,项目名称:Sigap,代码行数:9,代码来源:NearbyService.java


示例10: createCaseLocation

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
private void createCaseLocation(String caseId) {
    Location currentLocation = CacheManager.pluck().getUserLocation();
    FirebaseApi.pluck()
            .caseLocations()
            .setLocation(caseId,
                         new GeoLocation(currentLocation.getLatitude(),
                                         currentLocation.getLongitude()));
}
 
开发者ID:zetbaitsu,项目名称:Sigap,代码行数:9,代码来源:TombolPresenter.java


示例11: listenLocationUpdate

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
private void listenLocationUpdate() {
    locationProvider.getUpdatedLocation(request)
            .subscribe(location -> {
                if (StateManager.pluck().getState().equals(StateManager.State.LOGGED) ||
                        StateManager.pluck().getState().equals(StateManager.State.ADDING_TRUSTED_USER) ||
                        StateManager.pluck().getState().equals(StateManager.State.MENOLONG) ||
                        StateManager.pluck().getState().equals(StateManager.State.DITOLONG) ||
                        StateManager.pluck().getState().equals(StateManager.State.DIKAWAL) ||
                        StateManager.pluck().getState().equals(StateManager.State.MENGAWAL)) {
                    UserLocation userLocation = new UserLocation();
                    userLocation.setUserId(currentUser.getUserId());
                    userLocation.setLatitude(location.getLatitude());
                    userLocation.setLongitude(location.getLongitude());
                    CacheManager.pluck().cacheUserLocation(userLocation);
                    FirebaseApi.pluck()
                            .userLocations()
                            .setLocation(currentUser.getUserId(),
                                         new GeoLocation(userLocation.getLatitude(), userLocation.getLongitude()));
                    if (view != null) {
                        view.onLocationUpdated(userLocation);
                    }
                }
            }, throwable -> {
                Timber.e(throwable.getMessage());
                if (view != null) {
                    view.showError(throwable.getMessage());
                }
            });
}
 
开发者ID:zetbaitsu,项目名称:Sigap,代码行数:30,代码来源:LocationPresenter.java


示例12: onKeyMoved

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
@Override
public void onKeyMoved(String key, GeoLocation location) {
    // Move the marker
    Marker marker = this.markers.get(key);
    if (marker != null) {
        this.animateMarkerTo(marker, location.latitude, location.longitude);
    }
}
 
开发者ID:firebase,项目名称:geofire-java,代码行数:9,代码来源:SFVehiclesActivity.java


示例13: onCameraChange

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
@Override
public void onCameraChange(CameraPosition cameraPosition) {
    // Update the search criteria for this geoQuery and the circle on the map
    LatLng center = cameraPosition.target;
    double radius = zoomLevelToRadius(cameraPosition.zoom);
    this.searchCircle.setCenter(center);
    this.searchCircle.setRadius(radius);
    this.geoQuery.setCenter(new GeoLocation(center.latitude, center.longitude));
    // radius in km
    this.geoQuery.setRadius(radius/1000);
}
 
开发者ID:firebase,项目名称:geofire-java,代码行数:12,代码来源:SFVehiclesActivity.java


示例14: bitsForBoundingBox

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
public static int bitsForBoundingBox(GeoLocation location, double size) {
    double latitudeDegreesDelta = GeoUtils.distanceToLatitudeDegrees(size);
    double latitudeNorth = Math.min(90, location.latitude + latitudeDegreesDelta);
    double latitudeSouth = Math.max(-90, location.latitude - latitudeDegreesDelta);
    int bitsLatitude = (int)Math.floor(Utils.bitsLatitude(size)) *2;
    int bitsLongitudeNorth = (int)Math.floor(Utils.bitsLongitude(size, latitudeNorth)) *2 - 1;
    int bitsLongitudeSouth = (int)Math.floor(Utils.bitsLongitude(size, latitudeSouth)) *2 - 1;
    return Math.min(bitsLatitude, Math.min(bitsLongitudeNorth, bitsLongitudeSouth));
}
 
开发者ID:firebase,项目名称:geofire-java,代码行数:10,代码来源:GeoHashQuery.java


示例15: GeoHash

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
public GeoHash(double latitude, double longitude, int precision) {
    if (precision < 1) {
        throw new IllegalArgumentException("Precision of GeoHash must be larger than zero!");
    }
    if (precision > MAX_PRECISION) {
        throw new IllegalArgumentException("Precision of a GeoHash must be less than " + (MAX_PRECISION + 1) + "!");
    }
    if (!GeoLocation.coordinatesValid(latitude, longitude)) {
        throw new IllegalArgumentException(String.format(US, "Not valid location coordinates: [%f, %f]", latitude, longitude));
    }
    double[] longitudeRange = { -180, 180 };
    double[] latitudeRange = { -90, 90 };

    char[] buffer = new char[precision];

    for (int i = 0; i < precision; i++) {
        int hashValue = 0;
        for (int j = 0; j < Base32Utils.BITS_PER_BASE32_CHAR; j++) {
            boolean even = (((i*Base32Utils.BITS_PER_BASE32_CHAR) + j) % 2) == 0;
            double val = even ? longitude : latitude;
            double[] range = even ? longitudeRange : latitudeRange;
            double mid = (range[0] + range[1])/2;
            if (val > mid) {
                hashValue = (hashValue << 1) + 1;
                range[0] = mid;
            } else {
                hashValue = hashValue << 1;
                range[1] = mid;
            }
        }
        buffer[i] = Base32Utils.valueToBase32Char(hashValue);
    }
    this.geoHash = new String(buffer);
}
 
开发者ID:firebase,项目名称:geofire-java,代码行数:35,代码来源:GeoHash.java


示例16: onLocationResult

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
@Override
public void onLocationResult(String key, GeoLocation location) {
    if (future.isDone()) {
        throw new IllegalStateException("Already received callback");
    }

    if (location != null) {
        future.put(location(key, location.latitude, location.longitude));
    } else {
        future.put(noLocation(key));
    }
}
 
开发者ID:firebase,项目名称:geofire-java,代码行数:13,代码来源:TestCallback.java


示例17: NearbyHabitEventDataSource

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
/**
 * Initialize datasource on a particular location
 * @param loc the reference location
 * @param users list of user ids (following) to query for events
 */
public NearbyHabitEventDataSource(GeoLocation loc, ArrayList<String> users) {
    this.loc = loc;
    this.users = users;
    nearbyEvents = new ArrayList<>();
}
 
开发者ID:CMPUT301F17T13,项目名称:cat-is-a-dog,代码行数:11,代码来源:NearbyHabitEventDataSource.java


示例18: onKeyMoved

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
@Override
public void onKeyMoved(String key, GeoLocation location) {
}
 
开发者ID:zetbaitsu,项目名称:Sigap,代码行数:4,代码来源:NearbyService.java


示例19: onKeyEntered

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
@Override
public void onKeyEntered(String key, GeoLocation location) {
    // Add a new marker to the map
    Marker marker = this.map.addMarker(new MarkerOptions().position(new LatLng(location.latitude, location.longitude)));
    this.markers.put(key, marker);
}
 
开发者ID:firebase,项目名称:geofire-java,代码行数:7,代码来源:SFVehiclesActivity.java


示例20: distance

import com.firebase.geofire.GeoLocation; //导入依赖的package包/类
public static double distance(GeoLocation location1, GeoLocation location2) {
    return distance(location1.latitude, location1.longitude, location2.latitude, location2.longitude);
}
 
开发者ID:firebase,项目名称:geofire-java,代码行数:4,代码来源:GeoUtils.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java AttCertValidityPeriod类代码示例发布时间:2022-05-23
下一篇:
Java MultiSwipeRefreshLayout类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap