arc-jsapi How can I st_geometry using a lookup field? - oracle-sqldeveloper

I am using the st_geometry field and try to view the PNU code value.
I tried two ways.
oracle DB query.
select a.pnu from LP_PA_CBND_4600000000 a
where sde.st_contains(a.shape,
sde.st_point(177566.6728471977,160430.12935426735, 4))=1
When an event occurs, click the map object
i got the evt.mapPoint(x,y).
4 is my srid.
this way is took a long time. and query was down...
i used the arcgis api`s IdentifyParameters
my code is follows.
PoiClick : function(map, evt) {
G_evt =evt;
console.log("ClickPoint ==== "+evt.mapPoint);
var targetLayerId = 'LP_PA_CBND';
var url = map.Layers.getLayerInfo(targetLayerId).SVC_URL;
var map = map.getMap();
//파라미터 설정.
var idParams = new krcgis.core.tasks.IdentifyParameters();
G_idparams =idParams;
idParams.geometry = evt.mapPoint;
idParams.mapExtent = map.extent;
idParams.returnGeometry = true;
idParams.tolerance = 3;
idParams.layerOption = krcgis.core.tasks.IdentifyParameters.LAYER_OPTION_ALL;
idParams.width = map.width;
idParams.height = map.height;
krcgis.Function.GetPoiInfo(url, idParams);
return evt.mapPoint;
},
//POI 정보를 가져온다.
GetPoiInfo : function(url, idParams) {
idTask = new krcgis.core.tasks.IdentyfyTask(url);
idTask
.execute(idParams)
.addCallback(function (response) {
G_response = response;
if (response) {
return response;
}
})
.addErrback(function (error) {
console.log('GetPoiInfo result error=', error);
});
}
It could be obtained in this way code pnu.
However, this way is different from the value that gets pnu code depending on the zoom level.
I want to get a single pnu code in a single x, y values.
how to get pnu code?
Database table :

IdentifyTask can be a little tricky, because it takes into account zoom levels, therefor it doesn't always return the same results.
I suggest that you use QueryTask. Just one problem - it doesn't have tolerance parameter, but you can buffer your evt.mapPoint and get Polygon.

Related

get value for specific question/item in a Google Form using Google App Script in an on submit event

I have figured out how to run a Google App Script project/function on a form submit using the information at https://developers.google.com/apps-script/guides/triggers/events#form-submit_4.
Once I have e I can call e.response to get a FormResponse object and then call getItemResponses() to get an array of all of the responses.
Without iterating through the array and checking each one, is there a way to find the ItemResponse for a specific question?
I see getResponseForItem(item) but it looks like I have to somehow create an Item first?
Can I some how use e.source to get the Form object and then find the Item by question, without iterating through all of them, so I could get the Item object I can use with getResponseForItem(item)?
This is the code I use to pull the current set of answers into a object, so the most current response for the question Your Name becomes form.yourName which I found to be the easiest way to find responses by question:
function objectifyForm() {
//Makes the form info into an object
var myform = FormApp.getActiveForm();
var formResponses = myform.getResponses()
var currentResponse = formResponses[formResponses.length-1];
var responseArray = currentResponse.getItemResponses()
var form = {};
form.user = currentResponse.getRespondentEmail(); //requires collect email addresses to be turned on or is undefined.
form.timestamp = currentResponse.getTimestamp();
form.formName = myform.getTitle();
for (var i = 0; i < responseArray.length; i++){
var response = responseArray[i].getResponse();
var item = responseArray[i].getItem().getTitle();
var item = camelize(item);
form[item] = response;
}
return form;
}
function camelize(str) {
str = str.replace(/[\.,-\/#!$%\^&\*;:{}=\-_`~()#\+\?><\[\]\+]/g, '')
return str.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, function(match, index) {
if (+match === 0) return ""; // or if (/\s+/.test(match)) for white spaces
return index == 0 ? match.toLowerCase() : match.toUpperCase();
});
}
//Use with installable trigger
function onSubmittedForm() {
var form = objectifyForm();
Logger.log(form);
//Put Code here
}
A couple of important things.
If you change the question on the form, you will need to update your
code
Non required questions may or may not have answers, so check if answer exists before you use it
I only use installable triggers, so I know it works with those. Not sure about with simple triggers
You can see the form object by opening the logs, which is useful for finding the object names

How to send (pass) variables from client to server (within the mapReduce function in server) in Meteor?

I am working on GeoSpatial project which I am using MongoDB as database and Meteor for creating my app. I have used mapReduce in my query. in order to visualize the result of query I put Google map API in the meteor. To make long story short, I want to get some location as an Input from meteor app and when I click on the button, see the result in Google Map API (which is placed in Meteor app.
Now my problem is that I cannot pass the variables (the ones that I got from textbox) from client function to server side in meteor.
Here is some part of my code in client side (here I have passed text1 and text2 as an argument in call function):
var text2 = document.getElementById("coords2").value;
var text1 = document.getElementById("coords1").value;
Meteor.call("doMapReducePointQuery", text1, text2, function(error, result){
if(error){
console.error(error)
}
else{
console.log("It works!");
}....// continued
and here is the part of the code in server side:
if (Meteor.isServer) {
Meteor.methods({
'doMapReducePointQuery': function(txt1,txt2) {
pxx=parseInt(txt1);
pyy=parseInt(txt2);
console.log(pxx); **// here I can see the pxx and pyy**
console.log(pyy);
var mapFn = function () { **// in this function I cannot get the pxx and pyy**
var px = -83.215; // here I just manually set the number, here where i want to get value from the text box and set it to px and py
var py = 41.53;
var key= this._id;
var value={
id:this._id,
type: this.type,
};
if (this.geometry.minlon <= px && px <= this.geometry.maxlon && this.geometry.minlat <= py && py <= this.geometry.maxlat) {
emit(key, value);
}
};
var reduceFn = function (key, value) { ....... // continued
As I mentioned in comments within the code, I can pass txt1 and txt2 to the doMapReducePointQuery method but the I cannot access then access the coordinates within my mapReduce mapFn function. I need to use txt1 (px) and txt2 (py) values in mapFn.
I did some research about how to make a variable, global in meteor, some of the people used "scope", but they did not mentioned how.
I would be really appreciated if somebody help me!

Protractor: how to click all delete buttons in a page object

I have a table with 3 rows of data and 3 delete buttons. I want to delete all rows of data and so am trying to write a method in my page object to do so... this should be a snap but I can't get it to work. I'm trying it like this:
this.rows = element.all(by.repeater('row in rows'));
this.deleteAllFriends = function() {
this.rows.each(function(row) {
row.$('i.icon-trash').click();
})
};
But this throws an error:
Error: Index out of bound. Trying to access index:2, but locator: by.repeater("row in rows") only has 1 elements
So obviously, the index protractor expects next is no longer there, because it's been deleted. How can I work around this?
This also does not work and throws the same error:
this.deleteButtons = $$('i.icon-trash');
this.deleteAllFriends = function() {
this.deleteButtons.each(function(button) {
button.click();
});
};
This also doesn't work...
this.deleteAllFriends = function() {
while(this.deleteButton.isDisplayed()) {
this.deleteButton.click();
}
};
With today's version >= 1.3.0 of Protractor you are now be able to do this at once
$$('i.icon-trash').click();
feat(protractor): allow advanced features for ElementArrayFinder
I finally figured it out...
this.deleteButtons = $$('i.icon-trash'); // locator
this.deleteAllFriends = function() {
var buttons = this.deleteButtons;
buttons.count().then(function(count) {
while(count > 0) {
buttons.first().click();
count--;
}
})
};

dojo.data.ItemFileReadStore: Invalid item argument. while reloading data

I am facing a strange problem here. I have a Select box displaying Department field value. Onchange of the department option, I have to populate the grid. When the page loads first time, the onChange event works fine and the data gets loaded perfectly in the grid. When I change the Department in the Select box, I get error in firebug "dojo.data.ItemFileReadStore: Invalid item argument".
I checked the JSON returned from server and it is exactly same as the JSON loaded earlier. Here are the code snippet of my code
HTML
<div id="costCenter" data-dojo-type="dijit/form/Select" data-dojo-attach-point="costCenter" data-dojo-attach-event="onChange:loadStacks"></div>
JS
loadStacks: function() {
var requestParams = {};
requestParams.Action = "getStacks";
requestParams.callType = "ajaxCall";
requestParams.deptID = deptID;
var docData = null;
request.invokePluginService("MyPlugin", "UtilityService",
{
requestParams: requestParams,
requestCompleteCallback: lang.hitch(this, function(response) { // success
docData= response.Data;
var dataStore = new dojo.data.ItemFileReadStore({data: docData});
grid = dijit.byId("docGrid");
grid.attr('structure', docStructure);
grid.attr('store', dataStore);
grid.render();
})
}
);
}
JSON data returned:
docData : {"items":[{"docName":"test3","id":135,"order":1},{"docName":"Ashish","id":4085,"order":21},{"docName":"fsdfsadf","id":4088,"order":23}],"identifier":"docName"}
Any idea about it?
Solved it myself. Added below lines before setting new store to the grid.
if (null != grid.store)
{
grid.store.close();
grid.store.fetch({query: {docName: "*"}});
grid._refresh();
}
And set clearOnClose: true while setting new store.

send var js to django view in select dynamic

I am doing select dependent and I got a problem when making the query's, here the js
function cargar_paises() {
$.getJSON('cargar_paises', {}, function (data) {
$('#paises').empty();
$('#paises').append('<option value="0">Seleccione ...</option>');
$.each(data, function (id, desc) {
var option = $('<option></option>', {value:(id+1), text:desc});
$('#paises').append(option);
});
});
}
and my view
def cargar_paises(request):
if request.is_ajax:
pais = Pais.objects.all()
paises = []
for s in pais:
aux = []
id = s.pk
aux.append(id)
nombre = s.nombre
aux.append(nombre)
paises.append(aux)
return HttpResponse(json.dumps(paises), mimetype='aplication/json')
the problem is when I print the values ​​in the select and send the id to another query, the values ​​that I take are the index of the select and not the value of id_pais.
You can work this out a little better using a list of dictionaries instead of a list of lists, even using the dJango .values(), but to keep it simple, you ca use you exact same approach,
function cargar_paises() {
$.getJSON('cargar_paises', {}, function (data) {
$('#paises').empty();
$('#paises').append('<option value="0">Seleccione ...</option>');
$.each(data, function (item) {
var option = $('<option></option>', {value:item.id, text:item.nombre});
$('#paises').append(option);
});
});
}
and in the view,
def cargar_paises(request):
if request.is_ajax:
pais = Pais.objects.all()
paises = []
for s in pais:
aux = {}
aux['id'] = s.pk
aux['nombre'] = s.nombre
paises.append(aux)
return HttpResponse(json.dumps(paises), mimetype='aplication/json')
Remember, you can map Python dictionaries to Json objects, and python lists to Json arrays, another good hint is to use django-dajaxice it's a very good tool to do what you want, anyway is good to se this kind of things out of dJango.
Edit
I really thought about it, use the .values() in the query set, your view,
def cargar_paises(request):
if request.is_ajax:
paises = Pais.objects.values('id', 'nombre')
return HttpResponse(json.dumps(paises), mimetype='aplication/json')
you can find the documentation here.
try setting the id's as:
var option = $('<option></option>', {value:(paises[0].aux.id+1), text:desc});