Skip to main content
Solved

Data Download FME Server- JavaScript error- run if geometry is not drawn


ciarab
Contributor
Forum|alt.badge.img+9

Are there any javascript experts out there? I have created a data download web application where you draw a polygon and return some data. I have done this primarily from some samples made available on the knowledge base. It looks ok I have customized it a bit and added some extra functionality/background mapping.

This is all working very well when I draw my polygon and submit the request it goes to Server and my data returns.

Problem is I want to run the workspace even if a polygon is not defined/drawn - as in I have another parameter option to input x,y min and max values. I would like the workspace to submit without the polygon geometry part being drawn.

 

 

But when I try to do this I get the following error stating it can not read length

mapinfo.js:175 Uncaught TypeError: Cannot read property 'length' of undefined

at processClip (mapinfo.js:175)

at HTMLInputElement.onclick (mapinfo.html:1)

 

 

Can anyone tell me how I could get around this basically if its null ignore or something similar? I have tried a number of things but I am struggling to get anywhere.

 

If I run the url directly with the geom value empty the workspace runs fine

 

http://server/fmedatadownload/repository/workspace.fmw?INPUT_POLYGON=&INSERT_COORDS=&MITAB_VERSION=1150&QUARTER=DLM_CORE_2020Q1&OUTPUT_COORD_SYS=IRELAND-ITM&PRIME2_CLASS_YES_NO=No&CBD2019_YES_NO=Yes&NAME=Ciara Beddy&EMAIL=myemail&CUSTOMER=Test&GEOM=POLYGON(())

 

I have attached the javascript used -- any assistance would be greatly appreciated

Best answer by ebygomm

I am in no way a javascript expert but have you tried something like

if (clippingGeometry){
var geometry = "POLYGON((";

 for (var i = 0; i < clippingGeometry.length; i++) {
  var lat = clippingGeometry[i][1];
  var lng = clippingGeometry[i][0];
  geometry += lng + " " + lat + ",";

 }

 // Remove trailing , from string
 geometry = geometry.substr(0, geometry.length - 1);
 geometry += "))";


 params += "GEOM=" + geometry;
}
View original
Did this help you find an answer to your question?

2 replies

ebygomm
Influencer
Forum|alt.badge.img+33
  • Influencer
  • Best Answer
  • March 5, 2020

I am in no way a javascript expert but have you tried something like

if (clippingGeometry){
var geometry = "POLYGON((";

 for (var i = 0; i < clippingGeometry.length; i++) {
  var lat = clippingGeometry[i][1];
  var lng = clippingGeometry[i][0];
  geometry += lng + " " + lat + ",";

 }

 // Remove trailing , from string
 geometry = geometry.substr(0, geometry.length - 1);
 geometry += "))";


 params += "GEOM=" + geometry;
}

ciarab
Contributor
Forum|alt.badge.img+9
  • Author
  • Contributor
  • March 5, 2020
ebygomm wrote:

I am in no way a javascript expert but have you tried something like

if (clippingGeometry){
var geometry = "POLYGON((";

 for (var i = 0; i < clippingGeometry.length; i++) {
  var lat = clippingGeometry[i][1];
  var lng = clippingGeometry[i][0];
  geometry += lng + " " + lat + ",";

 }

 // Remove trailing , from string
 geometry = geometry.substr(0, geometry.length - 1);
 geometry += "))";


 params += "GEOM=" + geometry;
}

Thank you so much, i tried similar but got my brackets wrong. Appreciate the response !!


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings