Commit 48461f58 authored by Chris Scott's avatar Chris Scott

Add manual stationary exit detection

parent e60050c6
{
"images" : [
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "2x",
"filename" : "Icon-Small@2x.png"
},
{
"idiom" : "iphone",
"size" : "29x29",
"scale" : "3x",
"filename" : "Icon-Small@3x.png"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "2x",
"filename" : "Icon-40@2x.png"
},
{
"idiom" : "iphone",
"size" : "40x40",
"scale" : "3x",
"filename" : "Icon-40@3x.png"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "2x",
"filename" : "Icon-60@2x.png"
},
{
"idiom" : "iphone",
"size" : "60x60",
"scale" : "3x",
"filename" : "Icon-60@3x.png"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "1x",
"filename" : "Icon-Small.png"
},
{
"idiom" : "ipad",
"size" : "29x29",
"scale" : "2x",
"filename" : "Icon-Small@2x.png"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "1x",
"filename" : "Icon-40.png"
},
{
"idiom" : "ipad",
"size" : "40x40",
"scale" : "2x",
"filename" : "Icon-40@2x.png"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "1x",
"filename" : "Icon-76.png"
},
{
"idiom" : "ipad",
"size" : "76x76",
"scale" : "2x",
"filename" : "Icon-76@2x.png"
}
],
"info" : {
"version" : 1,
"author" : "makeappicon"
}
}
\ No newline at end of file
#!/usr/bin/env node
var platformDir = {
ios: {
icon: "{$projectName}/Resources/icons",
screen: "{$projectName}/Resources/splash",
nameMap: {
"Icon.png": "Icon.png",
"Icon@2x.png": "Icon@2x.png",
"Icon-40.png": "Icon-40.png",
"Icon-40@2x.png": "Icon-40@2x.png",
"Icon-60.png":"Icon-60.png",
"Icon-60@2x.png":"Icon-60@2x.png",
"Icon-Small-50.png":"Icon-50.png",
"Icon-Small-50@2x.png":"Icon-50@2x.png",
"Icon.png":"Icon.png",
"Icon@2x.png":"Icon@2x.png",
"Icon-72.png":"Icon-72.png",
"Icon-72@2x.png": "Icon-72@2x.png",
"Icon-76.png":"Icon-76.png",
"Icon-76@2x.png": "Icon-76@2x.png",
"Icon-Small.png": "Icon-Small.png",
"Icon-Small@2x.png":"Icon-Small@2x.png",
"screen-iphone-portrait.png": "Default~iphone.png",
"screen-iphone-portrait@2x.png": "Default@2x~iphone.png",
"screen-iphone-portrait-568h@2x.png": "Default-568h@2x~iphone.png",
"Default-Portrait~ipad.png": "Default-Portrait~ipad.png",
"Default-Portrait@2x~ipad.png": "Default-Portrait@2x~ipad.png"
}
},
android: {
icon:"res/drawable-{$density}",
screen:"res/drawable-{$density}",
nameMap: {
"icon-36-ldpi.png": "icon.png",
"icon-48-mdpi.png": "icon.png",
"icon-72-hdpi.png": "icon.png",
"icon-96-xhdpi.png": "icon.png",
"screen-ldpi-portrait.png": "ic_launcher.png",
"screen-mdpi-portrait.png": "ic_launcher.png",
"screen-hdpi-portrait.png": "ic_launcher.png",
"screen-xhdpi-portrait.png": "ic_launcher.png"
}
},
blackberry10: {},
wp7: {},
wp8: {}
}
var projectName = process.env['PWD'].split('/').pop();
var fs = require ('fs');
var path = require('path');
var platform = process.env.CORDOVA_PLATFORMS;
var platformConfig = platformDir[platform];
var srcRoot = path.join(process.cwd(), 'config', 'res');
var iconSrcPath = path.join(srcRoot, 'icon', platform);
var screenSrcPath = path.join(srcRoot, 'screen', platform);
var destRoot = path.join('platforms', platform);
var iconDestPath = path.join(destRoot, platformDir[platform].icon);
var screenDestPath = path.join(destRoot, platformDir[platform].screen);
fs.readFile("./config.xml", function(err, data) {
if (err) {
throw err;
}
var m = data.toString().match(/<name>(.*)<\/name>/);
if (!m) {
throw "Resource Copier script could not determine proeject name";
}
projectName = m[1];
console.log("- Copying icons and screen", platform);
copyImages(iconSrcPath, iconDestPath, platformConfig.icon);
copyImages(screenSrcPath, screenDestPath, platformConfig.screen);
});
/**
* Copy Images
*/
function copyImages(srcPath, destTpl) {
var re = /-([a-zA-Z]+dpi)/;
fs.readdir(srcPath, function(err, rs) {
if (err) {
console.log('ERROR could not find image dir at ', srcPath);
return;
}
for (var n=0,len=rs.length;n<len;n++) {
var filename = rs[n];
if (!platformConfig.nameMap[filename]) {
continue;
}
var sourcePath = path.join(srcPath, filename);
var m = filename.match(re);
var density;
if (m) {
density = m[1];
}
var dict = {
projectName: projectName,
density: density
};
var destRoot = destTpl.replace (/{\$([^}]+)}/, function (match, p1) {
return dict[p1];
});
var sourceFile = path.join(srcPath, filename);
var targetFile = path.join(destRoot, platformConfig.nameMap[filename]);
console.log(filename, '->', targetFile);
copyFile(sourceFile, targetFile, function() {
});
}
});
}
/**
* copyFile
*/
function copyFile(source, target, cb) {
var cbCalled = false;
var rd = fs.createReadStream(source);
rd.on("error", function(err) {
done(err);
});
var wr = fs.createWriteStream(target);
wr.on("error", function(err) {
done(err);
});
wr.on("close", function(ex) {
done();
});
rd.pipe(wr);
function done(err) {
if (!cbCalled) {
cb(err);
cbCalled = true;
}
}
}
......@@ -43,7 +43,6 @@ body {
height:100%;
margin:0px;
padding:0px;
text-transform:uppercase;
width:100%;
}
......@@ -59,12 +58,22 @@ body {
.header {
padding-top: 15px;
background-color: #fedd1e;
}
.header h3 {
text-transform:uppercase;
font-size:24px;
}
.header p, .header h3 {
font-weight:normal;
margin:0px;
overflow:visible;
padding:0px;
text-align:center;
}
.header p {
font-size: 1.3em;
}
#footer {
background-color: #fedd1e;
}
\ No newline at end of file
......@@ -34,7 +34,9 @@
</head>
<body>
<div id="header" class="header">
<h3>BG GeoLocation</h3>
<h3>BG GeoLocation</h3>
<p>transistorsoft.com</p>
</div>
<div id="map-canvas"></div>
......
......@@ -3,7 +3,7 @@
<plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="org.transistorsoft.cordova.background-geolocation"
version="0.3.5">
version="0.3.6">
<name>CDVBackgroundGeoLocation</name>
<description>Cordova Background GeoLocation Plugin</description>
<license>MIT</license>
......
......@@ -495,10 +495,27 @@
[locationManager setDistanceFilter:newDistanceFilter];
[self startUpdatingLocation];
}
} else if ([self locationIsBeyondStationaryRegion:location]) {
if (isDebugging) {
[self notify:@"Manual stationary exit-detection"];
}
[self setPace:YES];
}
[self queue:location type:@"current"];
}
/**
* Manual stationary location his-testing. This seems to help stationary-exit detection in some places where the automatic geo-fencing soesn't
*/
-(bool)locationIsBeyondStationaryRegion:(CLLocation*)location
{
NSLog(@"- CDVBackgroundGeoLocation locationIsBeyondStationaryRegion");
if (![stationaryRegion containsCoordinate:[location coordinate]]) {
double pointDistance = [stationaryLocation distanceFromLocation:location];
return (pointDistance - stationaryLocation.horizontalAccuracy - location.horizontalAccuracy) > stationaryRadius;
} else {
return NO;
}
}
/**
* Calculates distanceFilter by rounding speed to nearest 5 and multiplying by 10. Clamped at 1km max.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment