Linked Camera to game, and also fixed polygon last points are not equal
This commit is contained in:
@@ -36,31 +36,6 @@ export default class App extends Component<Props> {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
activeWalk: false,
|
||||
username: "",
|
||||
gameNumber: "",
|
||||
walkMarkers: [],
|
||||
captures: [
|
||||
// new CapturedArea("fanded", [
|
||||
// {latitude: -43.5623, longitude:172.5655},
|
||||
// {latitude: -43.5623, longitude:172.5650},
|
||||
// {latitude: -43.5628, longitude:172.5650},
|
||||
// {latitude: -43.5628, longitude:172.5655}
|
||||
// ], 'rgba(255,0,255, 1)', 'rgba(255,0,255, 0.2)', 53),
|
||||
|
||||
new CapturedArea("samded", [
|
||||
{latitude: -43.5663, longitude:172.5615},
|
||||
{latitude: -43.5663, longitude:172.5610},
|
||||
{latitude: -43.5668, longitude:172.5610},
|
||||
{latitude: -43.5668, longitude:172.5615}
|
||||
], 'rgba(0,0,255, 1)', 'rgba(0,0,255, 0.2)', 53)
|
||||
],
|
||||
watchID
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
let watchID = navigator.geolocation.watchPosition((position) => {
|
||||
console.log(this.state.activeWalk)
|
||||
if(this.state.activeWalk){
|
||||
@@ -80,6 +55,32 @@ export default class App extends Component<Props> {
|
||||
// }
|
||||
}, null, {enableHighAccuracy: true, timeout: 20000, distanceFilter: 10});
|
||||
|
||||
this.state = {
|
||||
activeWalk: false,
|
||||
username: "samded",
|
||||
gameNumber: "samdum",
|
||||
walkMarkers: [],
|
||||
captures: [
|
||||
// new CapturedArea("fanded", [
|
||||
// {latitude: -43.5623, longitude:172.5655},
|
||||
// {latitude: -43.5623, longitude:172.5650},
|
||||
// {latitude: -43.5628, longitude:172.5650},
|
||||
// {latitude: -43.5628, longitude:172.5655}
|
||||
// ], 'rgba(255,0,255, 1)', 'rgba(255,0,255, 0.2)', 53),
|
||||
|
||||
new CapturedArea("samded", [
|
||||
{latitude: -43.5663, longitude:172.5615},
|
||||
{latitude: -43.5663, longitude:172.5610},
|
||||
{latitude: -43.5668, longitude:172.5610},
|
||||
{latitude: -43.5668, longitude:172.5615}
|
||||
], 'rgba(0,0,255, 1)', 'rgba(0,0,255, 0.2)', 53)
|
||||
],
|
||||
watchID,
|
||||
activity: "map"
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
setInterval(() => {
|
||||
this.updateCaptures();
|
||||
}, 5000);
|
||||
@@ -104,6 +105,12 @@ export default class App extends Component<Props> {
|
||||
stopWalk(){
|
||||
console.log("stopping walk")
|
||||
sendArea(this.state.gameNumber, this.state.username, this.state.walkMarkers)
|
||||
.then(data => {
|
||||
console.log(data);
|
||||
if (data != []) {
|
||||
this.takePicture(data.polygonID);
|
||||
}
|
||||
});
|
||||
this.setState({activeWalk: false})
|
||||
|
||||
}
|
||||
@@ -111,41 +118,26 @@ export default class App extends Component<Props> {
|
||||
componentWillUnmount() {
|
||||
navigator.geolocation.stopWatch(this.state.watchID);
|
||||
}
|
||||
takePicture = async function() {
|
||||
|
||||
takePicture = async function(polygonID) {
|
||||
if (this.camera) {
|
||||
const options = { quality: 0.5, base64: true };
|
||||
const data = await this.camera.takePictureAsync(options)
|
||||
console.log(data.uri);
|
||||
this.setState({activity: "map"});
|
||||
}
|
||||
};
|
||||
|
||||
showCamera() {
|
||||
this.setState({activity: "takePicture"});
|
||||
}
|
||||
|
||||
|
||||
render() {
|
||||
|
||||
return (
|
||||
// <View style={styles.container}>
|
||||
// <RNCamera
|
||||
// ref={ref => {
|
||||
// this.camera = ref;
|
||||
// }}
|
||||
// style = {styles.preview}
|
||||
// type={RNCamera.Constants.Type.back}
|
||||
// flashMode={RNCamera.Constants.FlashMode.on}
|
||||
// permissionDialogTitle={'Permission to use camera'}
|
||||
// permissionDialogMessage={'We need your permission to use your camera phone'}
|
||||
// onGoogleVisionBarcodesDetected={({ barcodes }) => {
|
||||
// console.log(barcodes)
|
||||
// }}
|
||||
// />
|
||||
// <View style={{flex: 0, flexDirection: 'row', justifyContent: 'center',}}>
|
||||
// <TouchableOpacity
|
||||
// onPress={this.takePicture.bind(this)}
|
||||
// style = {styles.capture}
|
||||
// >
|
||||
// <Text style={{fontSize: 14}}> SNAP </Text>
|
||||
// </TouchableOpacity>
|
||||
// </View>
|
||||
// </View>
|
||||
let view = "";
|
||||
if (this.state.activity === "map") {
|
||||
view =
|
||||
<View style ={{flex: 1}}>
|
||||
<MapView
|
||||
showsUserLocation
|
||||
@@ -199,7 +191,34 @@ export default class App extends Component<Props> {
|
||||
</View>
|
||||
</View>
|
||||
</View>
|
||||
);
|
||||
} else if (this.state.activity === "takePicture") {
|
||||
view = <View style={styles.container}>
|
||||
<RNCamera
|
||||
ref={ref => {
|
||||
this.camera = ref;
|
||||
}}
|
||||
style = {styles.preview}
|
||||
type={RNCamera.Constants.Type.back}
|
||||
flashMode={RNCamera.Constants.FlashMode.on}
|
||||
permissionDialogTitle={'Permission to use camera'}
|
||||
permissionDialogMessage={'We need your permission to use your camera phone'}
|
||||
onGoogleVisionBarcodesDetected={({ barcodes }) => {
|
||||
console.log(barcodes)
|
||||
}}
|
||||
/>
|
||||
<View style={{flex: 0, flexDirection: 'row', justifyContent: 'center',}}>
|
||||
<TouchableOpacity
|
||||
onPress={this.takePicture.bind(this)}
|
||||
style = {styles.capture}
|
||||
>
|
||||
<Text style={{fontSize: 14}}> SNAP </Text>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
</View>
|
||||
}
|
||||
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,10 @@ module.exports = {
|
||||
let polygonResult = [];
|
||||
let polygonsMerged = [];
|
||||
polygons.map((polygon) => {
|
||||
if (polygon[0].lat != polygon[polygon.length - 1].lat &&
|
||||
polygon[0].lng != polygon[polygon.length - 1].lng) {
|
||||
polygon.push({lat: polygon[0].lat, lng: polygon[0].lng})
|
||||
}
|
||||
let intersect = module.exports.checkIntersects(polygonPoints, polygon.coords);
|
||||
if (intersect != null) {
|
||||
polygonPoints = module.exports.unionPolygon(polygonPoints, polygon.coords);
|
||||
|
||||
@@ -56,4 +56,8 @@
|
||||
<ele>20.00</ele>
|
||||
<time>2018-09-29T00:15:59Z</time>
|
||||
</wpt>
|
||||
<wpt lat="-43.56034430559162" lon="172.56487963850645">
|
||||
<ele>20.00</ele>
|
||||
<time>2018-09-29T00:16:00Z</time>
|
||||
</wpt>
|
||||
</gpx>
|
||||
+2
-2
@@ -13,12 +13,12 @@ export const sendArea = (gameID, username, polygon) => {
|
||||
formBody.push("points=" + JSON.stringify(points));
|
||||
formBody = formBody.join("&");
|
||||
console.log(formBody)
|
||||
fetch("http://"+config.host + ":" + config.port + "/v1/polygon", {
|
||||
return fetch("http://"+config.host + ":" + config.port + "/v1/polygon", {
|
||||
method: "post",
|
||||
headers: {'Content-Type':'application/x-www-form-urlencoded;charset=UTF-8'},
|
||||
body: formBody
|
||||
})
|
||||
.then(res => {return res.json()}).then(data => console.log(data));
|
||||
.then(res => {return res.json()});
|
||||
}
|
||||
|
||||
export const updateAreas = (gameID, update) => {
|
||||
|
||||
Reference in New Issue
Block a user