Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ROGUE-JCTD/arbiter
Browse files Browse the repository at this point in the history
  • Loading branch information
JStuhr committed Jan 24, 2013
2 parents 43c296c + 7a20929 commit ac8a0fa
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 40 deletions.
20 changes: 10 additions & 10 deletions .gitignore
Expand Up @@ -52,13 +52,13 @@ xcuserdata
########################
# Keep out icons local #
########################
Android/res/drawable-hdpi/icon.png
Android/res/drawable-ldpi/icon.png
Android/res/drawable-mdpi/icon.png
Android/res/drawable-xhdpi/icon.png
Android/res/drawable/icon.png
iOS/Arbiter/Resources/icons/icon.png
iOS/Arbiter/Resources/icons/icon@2x.png
iOS/Arbiter/Resources/icons/icon-72.png
iOS/Arbiter/Resources/icons/icon-72@2x.png
iOS/www/src/img/logo.png
/Android/res/drawable-hdpi/icon.png
/Android/res/drawable-ldpi/icon.png
/Android/res/drawable-mdpi/icon.png
/Android/res/drawable-xhdpi/icon.png
/Android/res/drawable/icon.png
/iOS/Arbiter/Resources/icons/icon.png
/iOS/Arbiter/Resources/icons/icon@2x.png
/iOS/Arbiter/Resources/icons/icon-72.png
/iOS/Arbiter/Resources/icons/icon-72@2x.png
/iOS/www/src/img/logo.png
4 changes: 4 additions & 0 deletions Android/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
org.eclipse.jdt.core.compiler.compliance=1.6
org.eclipse.jdt.core.compiler.source=1.6
Binary file removed Android/LatestBuilds/Arbiter_13Jan3_1041am.apk
Binary file not shown.
3 changes: 2 additions & 1 deletion iOS/www/src/index.html
Expand Up @@ -305,14 +305,15 @@ <h1 id="projectName">Map</h1>
<div id="idEditorMenu" style="position:absolute;z-index:2000;">
<div data-role="content" style="padding: 5px">
<ul id="editor-layer-list" data-role="listview" data-mini="true" style="padding:20px;"></ul>
<!--<div data-role="button" onClick="Arbiter.ToggleEditorMenu()">Done</div>-->
</div>
</div>

<div id="idAttributeMenu" style="position:absolute;z-index:2000;">
<div data-role="content" id="attributeMenuContent" style="padding: 5px">
<ul id="attribute-list" data-role="listview" data-mini="true" style="padding:20px;"></ul>
<input type="submit" value="Save" data-mini="true" onClick="Arbiter.SubmitAttributes()">
<input type="submit" value="Cancel" data-mini="true" onClick="Arbiter.ToggleAttributeMenu()">
<!--<input type="submit" value="Cancel" data-mini="true" onClick="Arbiter.ToggleAttributeMenu()">-->
</div>
</div>

Expand Down
56 changes: 29 additions & 27 deletions iOS/www/src/js/Arbiter.js
Expand Up @@ -815,7 +815,7 @@ var Arbiter = {
var attributeSql = "id integer primary key, fid text, " + layer.geomName + " text not null";

for(var i = 0; i < layer.attributes.length; i++){
attributeSql += ", " + layer.attributes[i] + " " + layer.attributeTypes[i].type;
attributeSql += ", '" + layer.attributes[i] + "' " + layer.attributeTypes[i].type;
if(layer.attributeTypes[i].notnull)
attributeSql += " not null";
}
Expand Down Expand Up @@ -869,10 +869,10 @@ var Arbiter = {
insertProjectsServer: function(serverId, serverName, success){
console.log("insertProjectsServer: " + serverId + ", " + serverName, success);

var insertServerSql = "INSERT INTO servers (server_id) VALUES (" + serverId + ");";
var insertServerSql = "INSERT INTO servers (server_id) VALUES (?);";
console.log(insertServerSql);

Cordova.transaction(Arbiter.currentProject.variablesDatabase, insertServerSql, [], function(tx, res){
Cordova.transaction(Arbiter.currentProject.variablesDatabase, insertServerSql, [serverId], function(tx, res){
success(serverId, serverName);
}, Arbiter.error);
},
Expand Down Expand Up @@ -942,7 +942,7 @@ var Arbiter = {
console.log("Add project " + Arbiter.squote(Arbiter.currentProject.name) + " to projects table...");

//Add the project name to the projects table in globle.db
Cordova.transaction(Arbiter.globalDatabase, "INSERT INTO projects (name) VALUES (" + Arbiter.squote(Arbiter.currentProject.name) + ");", [], function(tx, res){
Cordova.transaction(Arbiter.globalDatabase, "INSERT INTO projects (name) VALUES (?);", [Arbiter.currentProject.name], function(tx, res){

Arbiter.currentProject.variablesDatabase = Cordova.openDatabase("Arbiter/Projects/" + Arbiter.currentProject.name + "/variables", "1.0", "Variable Database", 1000000);
Arbiter.currentProject.dataDatabase = Cordova.openDatabase("Arbiter/Projects/" + Arbiter.currentProject.name + "/data", "1.0", "Data Database", 1000000);
Expand Down Expand Up @@ -1244,7 +1244,7 @@ var Arbiter = {
}, function(e){ console.log("Error reading tileIds - " + e); });

//open the editor tab. a hack to avoid the jumping feature bug
$("#editorTab").click();
Arbiter.ToggleEditorMenu();
}
},

Expand Down Expand Up @@ -1574,13 +1574,6 @@ var Arbiter = {
Arbiter.OpenAttributesMenu();
} else {
Arbiter.CloseAttributesMenu();
/*
if(attributeTab) {
if(selectedFeature) {
Arbiter.newWFSLayer.unselected(selectedFeature);
}
}
*/
}
},

Expand Down Expand Up @@ -1957,6 +1950,7 @@ var Arbiter = {
li += "<label for='radio-choice-" + Arbiter.radioNumber + "'>";
li += serverName + " / " + layerName;
li += "</label>";

Arbiter.radioNumber++;

//add the data from local storage
Expand Down Expand Up @@ -1984,14 +1978,15 @@ var Arbiter = {
}
}
}
Arbiter.radioNumber = 1;
},

setLayerAttributeInfo: function(serverList, layername, f_table_name){
console.log("layername: " + layername + ", f_table_name: " + f_table_name, serverList);
// get the geometry name, type, and srs of the layer
var geomColumnsSql = "SELECT * FROM geometry_columns where f_table_name='" + f_table_name + "';";
var geomColumnsSql = "SELECT * FROM geometry_columns where f_table_name=?;";

Cordova.transaction(Arbiter.currentProject.dataDatabase, geomColumnsSql, [], function(tx, res) {
Cordova.transaction(Arbiter.currentProject.dataDatabase, geomColumnsSql, [f_table_name], function(tx, res) {
var geomName;
//var server = Arbiter.currentProject.serverList[serverName];
var serverLayer = serverList.layers[layername];
Expand Down Expand Up @@ -2095,8 +2090,9 @@ var Arbiter = {
Cordova.transaction(Arbiter.currentProject.variablesDatabase, "DELETE FROM layers WHERE layername=?;", [layername], function(tx, res){
var server = Arbiter.currentProject.serverList[servername];
var layer = server.layers[layername];
//TODO: check all statements for end ;
Cordova.transaction(Arbiter.currentProject.dataDatabase, "DELETE FROM geometry_columns WHERE f_table_name=?", [layer.featureType], function(tx, res){
Cordova.transaction(Arbiter.currentProject.dataDatabase, "DROP TABLE " + layer.featureType, [], function(tx, res){
Cordova.transaction(Arbiter.currentProject.dataDatabase, "DROP TABLE " + layer.featureType + ";", [], function(tx, res){
console.log("before_delete: success! " + servername + ", " + layername);

//TODO: why is destroy not working?
Expand Down Expand Up @@ -3166,7 +3162,7 @@ var Arbiter = {
readLayerFromDb: function(tableName, layerName, geomName, srsName){
var layer = map.getLayersByName(layerName + "-wfs")[0];
console.log("readLayerFromDb: " + tableName + ", " + layerName + ", " + geomName + ", " + srsName);
Cordova.transaction(Arbiter.currentProject.dataDatabase, "SELECT * FROM " + tableName, [], function(tx, res){
Cordova.transaction(Arbiter.currentProject.dataDatabase, "SELECT * FROM " + tableName + ";", [], function(tx, res){
for(var i = 0; i < res.rows.length;i++){
var row = res.rows.item(i);

Expand All @@ -3191,7 +3187,7 @@ var Arbiter = {
}

//after the transaction is complete, check to see which features are dirty
Cordova.transaction(Arbiter.currentProject.variablesDatabase, "SELECT * FROM dirty_table where f_table_name='" + tableName + "';", [], function(tx, res){
Cordova.transaction(Arbiter.currentProject.variablesDatabase, "SELECT * FROM dirty_table where f_table_name=?;", [tableName], function(tx, res){
for(var i = 0; i < res.rows.length;i++){
var feature = layer.getFeatureByFid(res.rows.item(i).fid);
feature.modified = true;
Expand Down Expand Up @@ -3548,7 +3544,8 @@ var Arbiter = {
var protocol = selectedFeature.layer.protocol;
Arbiter.insertFeaturesIntoTable([selectedFeature], protocol.featureType, protocol.geometryName, protocol.srsName, true);

Arbiter.ToggleAttributeMenu();
//this should go back in when the feature selection bug is fixed
//Arbiter.ToggleAttributeMenu();
}else{
$("#saveAttributesFailed").fadeIn(1000, function(){
$(this).fadeOut(3000);
Expand Down Expand Up @@ -3728,7 +3725,7 @@ var Arbiter = {
//Arbiter.deleteLayerCount++;
Arbiter.deleteLayer(meta.serverName, meta.nickname);
}else{
Cordova.transaction(Arbiter.currentProject.dataDatabase, "DELETE FROM " + featureType, [], function(tx, res) {
Cordova.transaction(Arbiter.currentProject.dataDatabase, "DELETE FROM '" + featureType + "';", [], function(tx, res) {
// pull everything down
wfsLayer.destroyFeatures();
console.log("pull after delete");
Expand Down Expand Up @@ -3764,9 +3761,13 @@ var Arbiter = {
var newWFSLayer = new OpenLayers.Layer.Vector(meta.nickname + "-wfs", {
strategies : strategies,
projection : new OpenLayers.Projection(meta.srsName),
protocol : protocol,
styleMap: styleMap
protocol : protocol
});

if (serverLayer.geometryType === "Point") {
alert('setting stylemap for: ' + meta.nickname);
newWFSLayer.styleMap = styleMap;
}

newWFSLayer.attributeTypes = {};

Expand Down Expand Up @@ -3818,25 +3819,26 @@ var Arbiter = {
}
});

var poiInBounds;
var featureInBounds;
newWFSLayer.events.register("beforefeatureadded", null, function(event) {
//if in bounds
if(Arbiter.currentProject.aoi.contains(event.feature.geometry.x, event.feature.geometry.y)) {
poiInBounds = true;
// if(Arbiter.currentProject.aoi.contains(event.feature.geometry.x, event.feature.geometry.y)) {
if(Arbiter.currentProject.aoi.intersectsBounds(event.feature.geometry.getBounds())) {
featureInBounds = true;
return true;
}

//if out of bounds
console.log('Feature is out of bounds');
poiInBounds = false;
console.log('Feature is out of bounds:', event.feature);
featureInBounds = false;
return false;
});

var addFeatureControl = new OpenLayers.Control.DrawFeature(newWFSLayer, OpenLayers.Handler.Point);
var selectControl = new OpenLayers.Control.SelectFeature( newWFSLayer, OpenLayers.Handler.Point);

addFeatureControl.events.register("featureadded", null, function(event) {
if(poiInBounds == false) {
if(featureInBounds == false) {
return false;
}
// populate the features attributes object
Expand Down
4 changes: 2 additions & 2 deletions iOS/www/src/js/Cordova.js
Expand Up @@ -153,13 +153,13 @@ var Cordova = {
if(_success)
_success(tx, res);
}, function(tx, err){
Arbiter.error("Cordova.transaction: sql execution failed!!!", tx, err);
Arbiter.error("Cordova.transaction: sql execution failed!", tx, err, _sql, _variables);
if(_error){
_error(tx, err);
}
});
}, function(err, err2){
Arbiter.error("Transaction failed!!!", err, err2);
Arbiter.error("Transaction failed!", err, err2, _sql, _variable);
}, function(){
// do nothing
});
Expand Down
19 changes: 19 additions & 0 deletions iOS/www/src/js/TileUtil.js
Expand Up @@ -1172,6 +1172,25 @@ dumpTableRows: function(database, tableName){
});
},


dumpTableAttributes: function(database, tableName){
console.log("---- TileUtil.dumpTableAttributes");

// get the attributes of the layer
var sql = "PRAGMA table_info (" + tableName + ");";

Cordova.transaction(Arbiter.currentProject.dataDatabase, sql, [], function(tx, res) {
var str = 'attribute count: ' + res.rows.length + '\n';
for (var i=0; i<res.rows.length; i++) {
var attr = res.rows.item(i);
str += 'name: ' + attr.name + ', type: ' + attr.type + ', notnull: ' + attr.notnull + '\n';
}

console.log(str);

}, Arbiter.error);
},

rowsToString: function(rows) {
var rowsStr = "rows.length: " + rows.length + "\n";
for(var i = 0; i < rows.length; i++){
Expand Down

0 comments on commit ac8a0fa

Please sign in to comment.