PyPi中的Location.watchPositionAsync
和import React, { Component } from "react";
import { StyleSheet, View } from "react-native";
import MapView from "react-native-maps";
import * as Location from "expo-location";
import * as Permissions from "expo-permissions";
import * as TaskManager from "expo-task-manager";
const LOCATION_TASK_NAME = "background-location-task";
export default class App extends Component {
constructor(props) {
super(props);
this.state = {
region: null,
error: '',
};
}
_getLocationAsync = async () => {
console.log(`entered _getLocationAsync`)
await Location.startLocationUpdatesAsync(LOCATION_TASK_NAME, {
enableHighAccuracy: true,
distanceInterval: 1,
timeInterval: 5000
});
console.log(`start watchPositionAsync`)
// watchPositionAsync Return Lat & Long on Position Change
this.location = await Location.watchPositionAsync(
{
enableHighAccuracy: true,
distanceInterval: 1,
timeInterval: 10000
},
newLocation => {
let { coords } = newLocation;
// console.log(coords);
let region = {
latitude: coords.latitude,
longitude: coords.longitude,
latitudeDelta: 0.045,
longitudeDelta: 0.045
};
console.log(`watchPositionAsync ${coords.latitude}, ${coords.longitude}`)
this.setState({ region: region });
},
error => console.log(error)
);
return this.location;
};
async componentWillMount() {
// Asking for device location permission
const { status } = await Permissions.askAsync(Permissions.LOCATION);
if (status === "granted") {
this._getLocationAsync();
} else {
this.setState({ error: "Locations services needed" });
}
}
render() {
return (
<View style={styles.container}>
<MapView
initialRegion={this.state.region}
showsCompass={true}
showsUserLocation={true}
rotateEnabled={true}
ref={map => {
this.map = map;
}}
style={{ flex: 1 }}
/>
</View>
);
}
}
TaskManager.defineTask(LOCATION_TASK_NAME, async ({ data, error }) => {
if (error) {
console.log(error);
return;
}
if (data) {
const { locations } = data;
let lat = locations[0].coords.latitude;
let long = locations[0].coords.longitude;
console.log(`TaskManager:- ${lat}, ${long}`)
}
});
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff"
}
});
有什么区别?
tf-nightly
哪个可靠?
答案 0 :(得分:1)
Nightly用于获取较早的最新tensorflow开发思路,该版本每天更新。与浏览器(see here)相同。
哪个可靠?
经典的tensorflow pip install tensorflow
是两者中最可靠的。此版本在发布之前已经过很多人的测试。
答案 1 :(得分:1)
只需添加到BSO编写的内容中即可:
顾名思义,tf-nightly
pip软件包每晚都会生成并发布到PyPI(除非有任何生成失败的情况,这种情况很少发生)。结果,您可以看到一个almost once-per-day version update history。它具有接近github.com/tensorflow master分支的HEAD的最新功能。因此,如果您需要最新的功能,改进和错误修复,例如在上一个稳定的tensorflow
版本之后提交的功能(请参见下文),则应使用pip install tf-nightly
。但是不利的是,由于tf-nightly
版本不受tensorflow
相同的严格版本测试的限制,因此偶尔会包含一些错误,这些错误将在以后修复。另外,由于它是从HEAD构建的,因此将反映中间开发状态,例如功能不完整。
tensorflow
pip包由基于语义版本的计划发布。新版本大约2-6个月推出一次。由于具有全面的发布测试作业集,因此质量要高于tf-nightly
。 tensorflow
pip软件包中每个次要版本变更都会对https://www.tensorflow.org/api_docs/python/上的文档进行一次更新。