POST
|
Here is a similar solution using a PowerShell script loop. ------------------- $py_path="c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe" $py_script="c:\temp\ps_Process.py" $log_file="c:\temp\ps_log.txt" $RandID = Get-Random -Minimum 1000 -Maximum 9999 $EMAIL_TO = "xyz@name.com" $EMAIL_SUBJECT = "PS Loop Test" $EMAIL_FROM = "abc@name.com" $EMAIL_SERVER = "server_ip" # Logging function to write to a text file. Function Log { param( [Parameter(Mandatory=$true)][String]$msg ) $FormattedDate = Get-Date -Format "MM-dd-yyyy hh:mm:ss tt" Add-Content $log_file "$("PS")-$($RandID) $(" ") $($FormattedDate) $(" ") $($msg)" } Log "##########################################################" Log "Start PowerShell" $SUCCESS=1 # init to failed. $py_return="" for ($i = 0; $i -lt 10; $i++){ & $py_path $py_script if($LASTEXITCODE -eq 0){ # success Log "$i python.exe attempt success." $SUCCESS=0 break } else { Log "$i python.exe attempt failed (LASTEXITCODE = $LASTEXITCODE)" } Start-Sleep -Seconds 5.0 } Log "LASTEXITCODE= $LASTEXITCODE" Log "ERROR= $ERROR" Log "?= $?" if ($SUCCESS -eq 0) { Log "Python.exe ran successfully." $py_return="SUCCESS" } else { Log "Python.exe failed." $py_return="FAILED" } $SUBJECT="$EMAIL_SUBJECT - $py_return" Send-MailMessage -From $EMAIL_FROM -To $EMAIL_TO -Subject $SUBJECT -Body "($py_return) Result from python." -SmtpServer $EMAIL_SERVER Log "End PowerShell"
... View more
09-08-2021
05:53 AM
|
0
|
0
|
1866
|
POST
|
Here's a more complete DOS batch file that uses a loop to check return codes from the python.exe. It will repeat the loop until it gets a return code == 0 or until the maximum number of tries is reached. So far, I haven't seen it go over 7 tries. Note: This is only checking the problem where Windows Task Scheduler is not executing python.exe. It is not checking to see if there was an error within the python script. -------------------------------- SET log_file=c:\temp\Log.txt ECHO ######################################################################### >> %log_file% ECHO Batch start %date% Time: %time% >> %log_file% SET /A _counter=1 SET /A _max_tries=21 SET /A _wait_seconds=2 :LOOP IF %_counter%==%_max_tries% ( ECHO GOTO END - max tries of [%_max_tries%] reached. >> %log_file% GOTO :END ) ECHO Attempt: [%_counter%] >> %log_file% ECHO Error level before python: [%errorlevel%] >> %log_file% :: Use the python exe to run our batch script. :: Use full path to both python exe and python script. "c:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\pythonw.exe" c:\temp\process.py ECHO Error level after python: [%errorlevel%] >> %log_file% :: Check the python return code. If success then exit Else pause and try again. IF %errorlevel%==0 ( ECHO GOTO END - success >> %log_file% GOTO :END ) ELSE ( ECHO Wait for some time. >> %log_file% TIMEOUT %_wait_seconds% > NUL ) ECHO After pause %date% Time: %time% >> %log_file% :: Increment the counter. SET /A _counter=%_counter%+1 GOTO :LOOP :END ECHO Batch end %date% Time: %time% >> %log_file%
... View more
09-07-2021
09:47 AM
|
1
|
1
|
1903
|
POST
|
Did you find a solution? I'm interested in the same thing. Some 3rd party software to create a 3D model of an ellipsoid and then import it to Pro seems problematic. I think of problems lining up coordinate systems on the exported and imported object.
... View more
05-15-2020
08:14 AM
|
0
|
0
|
1044
|
POST
|
I'm trying to add or create an ellipsoid in an ArcGIS Pro local scene between two xyz points above ground. The distance between the two points is 8 miles. The ellipsoid radius is 50 feet. The points are 150 and 180 feet above ground, respectively. The points are described by latitude, longitude and height above ground. I've tried line-of-sight lines and buffered them in 3D. This gives a cylinder that is pretty good but the ellipsoid would be a better representation of reality. This picture below is the closest I've been able to get but it's far from usable. This will be used in 3D analysis so it needs to be spot on the locations. The attempt pictured started with a multipatch sphere. It is pitched 90 degrees on its side and stretched using the modify/scale tool. I need some way to move the object so that it can snap to the points. What might be ideal would be a GP tool or python script to create this ellipsoid from scratch. Given the two major axis z-value endpoints and the radius, create the object. The points represent radio antennas on towers and the ellipsoid represents the radio wave clearance zone or Fresnel zone. I've started looking at Blender and SketchUp but I don't know either package and would prefer a native ArcGIS solution. Any help will be appreciated. Thanks, Bill
... View more
05-13-2020
10:30 AM
|
0
|
1
|
518
|
BLOG
|
Are to tools still available? When I click on the link to it gives me the following message.
... View more
05-08-2020
01:49 PM
|
0
|
0
|
3928
|
POST
|
Shwu-jing Jeng, Thank you for your quick response and letting me know about the new Mode and Status properties. I may use them in the future. It looks like adding a unique constraint on a field in the feature layer will work for our workflow. This provides a clean error result in the Outbox when the user tries to submit a survey with a duplicate value for the unique constraint field. Add a unique constraint to a field Thanks, Bill
... View more
05-08-2020
08:26 AM
|
2
|
3
|
3610
|
POST
|
My goal is to prevent duplicate survey records from getting entered into the hosted feature service. I would like for the survey submittal to act similar to a database form when you try to insert a record with a duplicate key, it throws an error and aborts. I would like the survey to check for a unique ID to see if it already exists in the feature service records. If it already exists then an error message is presented to the user telling them of the problem and the submittal is aborted. If no record exists with the key then the submittal goes through. Is this kind of behavior possible using Survey123 and the hosted feature service? In this post, I see how the surveys are moved to the Sent box when they are successfully submitted but that is not quite what we are looking for. Survey 123 Data in Sent folder not received in database Thanks, Bill
... View more
05-07-2020
01:11 PM
|
1
|
6
|
3820
|
POST
|
When trying to use the 3D Analyst Line of Sight tool with the scene default WorldElevation3D/Terrain3D as the parameter for Input Surface, I get the following error. ERROR 000732 Input Surface: Dataset https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer does not exist or is not supported How can I use this dataset with the LOS tool? This is ArcGIS Pro 2.5 Thanks, Bill
... View more
04-02-2020
01:27 PM
|
0
|
0
|
461
|
POST
|
I'm trying to extrude by a value in an attribute field for multipatch features. It seems the Extrusion options on the Appearance tab are disabled (greyed out). This is within a local Scene. It will let me extrude the multipatch features using the 3D handle (from there I can enter a height value) but I would like to use an attribute field instead. It will let me extrude a polygon feature class using an attribute field but not the multipatch feature class. This is not an imported scene. I'm in ArcGIS Pro 2.5. The multipatch layer has a horizontal and vertical spatial reference. I've been using this as a reference Define height characteristics for layers Thanks Bill
... View more
04-01-2020
10:48 AM
|
0
|
2
|
986
|
POST
|
Ken, When you swapped out the layer and values returned, that surprised me. Then, when you asked about my map service setup, you got me looking harder at everything that I had glossed over before. My published map service looked alright. Nothing strange. So, looking harder at my code, I found my dumb mistake. I had set up my query wrong. the 'returnGeometry' setting was set to false. I changed it to true and got good results from the lines you provided. Thank you very much for taking the time to get me over this hurdle. Now I can have a good weekend and I hope you have one too. from this... IAH_Elev_FLayer .queryFeatures({ geometry: mapPoint, spatialRelationship: "intersects", returnGeometry: false, outFields: ["*"] }) to this... IAH_Elev_FLayer .queryFeatures({ geometry: mapPoint, spatialRelationship: "intersects", returnGeometry: true, outFields: ["*"] }) Thanks, Bill
... View more
01-24-2020
07:01 AM
|
0
|
0
|
2221
|
POST
|
Robert, yes the ObjectID and shape fields are not hidden. I can retrieve values for them. Ken, I will look more closely at how the service is set up. Hopefully something will look odd. Thank you.
... View more
01-24-2020
06:30 AM
|
0
|
0
|
2221
|
POST
|
Ken, Each of the featureLayers are polygons. Thanks, Bill
... View more
01-23-2020
12:14 PM
|
0
|
2
|
2221
|
POST
|
Ken, Thanks for taking a look. <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> <title>HAS javascript api 4.13</title> <link rel="stylesheet" href="https://js.arcgis.com/4.13/esri/themes/light/main.css" /> <script src="https://js.arcgis.com/4.13/"></script> <style> html, body, #viewDiv { height: 100%; width: 100%; margin: 0; padding: 0; } #optionsDiv { background-color: white; color: black; padding: 6px; max-width: 400px; } </style> <script> //let buildPopupContent; // fn used later to build popup content. require([ "esri/Map", "esri/Graphic", "esri/views/MapView", "esri/layers/FeatureLayer", "esri/PopupTemplate", "esri/geometry/Polygon", "esri/geometry/Point", "esri/geometry/Geometry" ], function(Map, Graphic, MapView, FeatureLayer, PopupTemplate, Polygon, Point, Geometry, webMercatorUtils) { let tier_FLayer = new FeatureLayer({ url: "http://10.88.22.95:6080/arcgis/rest/services/HAS/HAS_wm/MapServer/9", outFields: ["*"] }); let IAH_Elev_FLayer = new FeatureLayer({ url: "http://10.88.22.95:6080/arcgis/rest/services/HAS/HAS_wm/MapServer/7", outFields: ["*"] }); IAH_Elev_FLayer.visible = false; let EFD_HOU_Elev_FLayer = new FeatureLayer({ url: "http://10.88.22.95:6080/arcgis/rest/services/HAS/HAS_wm/MapServer/8", outFields: ["*"], }); EFD_HOU_Elev_FLayer.visible = false; let map = new Map({ basemap: "streets" ,layers: [tier_FLayer, IAH_Elev_FLayer, EFD_HOU_Elev_FLayer] }); let view = new MapView({ container: "viewDiv", map: map, center: [-95.4, 29.80], zoom: 11, popup: { autoOpenEnabled: false, dockEnabled: true, dockOptions: { // dock popup at bottom-right side of view buttonEnabled: false, breakpoint: false, position: "top-right" } } }); //create graphic for mouse point click let pointGraphic = new Graphic({ symbol: { type: "simple-marker", // autocasts as new SimpleMarkerSymbol() color: [0, 0, 139], outline: { color: [255, 255, 255], width: 1.0 } } }); tier_FLayer.load().then(function() { tier_FLayer.popupTemplate = popupTemplate; }); IAH_Elev_FLayer.load().then(function() { IAH_Elev_FLayer.popupTemplate = popupTemplate; }); EFD_HOU_Elev_FLayer.load().then(function() { EFD_HOU_Elev_FLayer.popupTemplate = popupTemplate; }); let popupTemplate = { title: "Airport Tier: {Tier}", content: buildPopupContent }; // When the feature is clicked, this function is called. The feature is passed into the function. https://developers.arcgis.com/javascript/latest/sample-code/popuptemplate-function/index.html function buildPopupContent (feature) { console.log("feature type = " + feature.graphic.geometry.type); // ERROR: Unable to get property 'type' of undefined or null reference console.log("centroid x " + feature.graphic.geometry.centroid.x); // ERROR: Unable to get property 'centroid' of undefined or null reference console.log("extent center x = " + feature.graphic.geometry.extent.center.x); // ERROR: Unable to get property 'extent' of undefined or null reference alert("ObjectId= " + feature.graphic.getAttribute("OBJECTID")); // works alert("area= " + feature.graphic.getAttribute("Shape.area")); // works alert("length= " + feature.graphic.getAttribute("Shape.len")); // works alert("GL= " + feature.graphic.attributes.GL); // works alert("GL= " + feature.graphic.getAttribute("GL")); // works let pointLatDMS = new DMS(feature.latitude); // feature converted to degree minute second. let pointLongDMS = new DMS(feature.longitude); let div = document.createElement("div"); div.innerHTML = "<b>Check values and click submit to send to the FAA website.</b></br></br>" + "<form action='https://oeaaa.faa.gov/oeaaa/external/gisTools/gisAction.jsp?action=doNoNoticeRequiredTool' target='_blank' method='POST'>" + "<table border='0' cellpadding='0' cellspacing='0' width='800'>" + "<tr>" + "<td width='20%'> Latitude: </td>" + "<td width='80%'><input type='text' name='latD' id='latD' size='3' maxlength='3' value=" + pointLatDMS.Degree + " tabindex=''> Deg <input type='text' name='latM' id='latM' size='2' maxlength='2' value=" + pointLatDMS.Minute + " tabindex=''> M <input type='text' name='latS' id='latS' size='5' maxlength='5' value=" + pointLatDMS.Second + " tabindex=''> S <select name='latDir' id='latDir' tabindex=''><option value='N'>N</option><option value='S'>S</option></select> </td>" + "</tr>" + "<tr>" + "<td> Longitude: </td>" + "<td><input type='text' name='longD' id='longD' size='3' maxlength='3' value=" + pointLongDMS.Degree + " tabindex=''> Deg <input type='text' name='longM' id='longM' size='2' maxlength='2' value=" + pointLongDMS.Minute + " tabindex=''> M <input type='text' name='longS' id='longS' size='5' maxlength='5' value=" + pointLongDMS.Second + " tabindex=''> S <select name='longDir' id='longDir' tabindex=''><option value='W'>W</option><option value='E'>E</option></select> </td>" + "</tr>" + "<TR>" + "<TD>Horizontal Datum:</TD>" + "<TD><select name='datum' id='datum' tabindex=''><option value='NAD83'>NAD83</option><option value='NAD27' selected >NAD27</option></select></TD>" + "</TR>" + "<TR>" + "<TD>Site Elevation (SE):</TD>" + "<TD><input type='text' name='siteElevation' id='siteElevation' size='5' maxlength='5' value=" + feature.graphic.attributes.GL + " tabindex=''> (nearest foot) </TD>" + "</TR>" + "<TR>" + "<TD>Structure Height (AGL):</TD>" + "<TD><input type='text' name='structureHeight' id='structureHeight' size='5' maxlength='5' value='222' tabindex=''> (nearest foot)</TD>" + "</TR>" + "<TR>" + "<TD>Airspace Elevation (AGL):</TD>" + "<TD><input type='text' name='airspaceElevationAGL' id='airspaceElevationAGL' size='5' maxlength='5' value='444'></TD>" + "</TR>" + "<TR>" + "<TD>Airspace Elevation (AMSL):</TD>" + "<TD><input type='text' name='airspaceElevationAMSL' id='airspaceElevationAMSL' size='5' maxlength='5' value='555'></TD>" + "</TR>" + "<TR>" + "<TD>Maximum Building Height:</TD>" + "<TD><input type='text' name='maxBldgHeight' id='maxBldgHeight' size='5' maxlength='5' value='350'></TD>" + "</TR>" + "<TR>" + "<TD>Airport Tier:</TD>" + "<TD><input type='text' name='airportTier' id='airportTier' size='20' maxlength='20' value=" + feature.graphic.attributes.Tier + "></TD>" + "</TR>" + "<TR>" + "<TD >Traverseway:</TD>" + "<TD ><select name='traverseway' id='traverseway' tabindex=''><option value='NO'>No Traverseway</option><option value='IH'>Interstate Highway</option><option value='OT'>Other Traverseway</option><option value='PR'>Private Road</option><option value='PH'>Public Roadway</option><option value='RR'>Railroad</option><option value='WW'>Waterway</option></select></TD>" + "</TR>" + "<TR>" + "<TD>Is structure on airport:</TD>" + "<TD><select name='onAirport' id='onAirport' tabindex=''><option value='false'>No</option><option value='true' selected >Yes</option></select></TD>" + "</TR>" + "<TR>" + "<td> </td>" + "<input type='submit' value='Submit to FAA Website'>" + "</TR>" + "</table> " + "</form>" return div; }; // end function buildPopupContent (feature) // Constructor function for DMS objects. https://www.w3schools.com/js/tryit.asp?filename=tryjs_object_constructor function DMS(coordInMeters) { this.Degree = "11"; this.Minute = "22"; this.Second = "33"; // To do: convert to degree minute secons // How to Convert Decimal Degrees to DMS // 1.For the degrees use the whole number part of the decimal. // 2.For the minutes multiply the remaining decimal by 60. Use the whole number part of the answer as minutes. // 3.For the seconds multiply the new remaining decimal by 60 }; // Workflow // User will click on the Airport Tiers polygon layer. // A point symbol is added to the map. // Depending on which Airport is clicked on (HOU,IAH,EFD), // the corresponding Airport Elevation layer will be queried. // Elevation info results will populate the popup. view.on("click", function(event) { view.graphics.remove(pointGraphic); //view.popup.remove(); // query Tiers layer. queryFeatures_Tiers(event); }); function queryFeatures_Tiers(screenPoint) { // Converts the given screen point to a map point. This mapPoint is in the units of the map (meters). const mapPoint = view.toMap(screenPoint); tier_FLayer .queryFeatures({ geometry: mapPoint, spatialRelationship: "intersects", returnGeometry: false, outFields: ["*"] }) .then(function(featureSet) { // Note: This function isn't executed when no Tier is returned. // set graphic location to mouse pointer and add to mapview pointGraphic.geometry = mapPoint; view.graphics.add(pointGraphic); //const graphics = results.features; let strTier = featureSet.features[0].attributes["Tier"]; //alert(strTier); // Check user clicked on a Tier polygon // "Hobby", "Ellington", "GBIA" if (strTier.indexOf("GBIA") > -1) { queryFeatures_IAH(mapPoint); } else if (strTier.indexOf("Hobby") > -1) { queryFeatures_EFD_HOU(mapPoint); } else if (strTier.indexOf("Ellington") > -1) { queryFeatures_EFD_HOU(mapPoint); } else { // This is never called. alert("Please click on one of the airports.") } }); } // end queryFeatures_Tiers() function queryFeatures_IAH(mapPoint) { //const point = view.toMap(screenPoint); IAH_Elev_FLayer .queryFeatures({ geometry: mapPoint, spatialRelationship: "intersects", returnGeometry: false, outFields: ["*"] }) .then(function(featureSet) { // open popup of query result view.popup.open({ location: mapPoint, features: featureSet.features, featureMenuOpen: true }); }); } // end queryFeatures_IAH() function queryFeatures_EFD_HOU(mapPoint) { EFD_HOU_Elev_FLayer .queryFeatures({ geometry: mapPoint, spatialRelationship: "intersects", returnGeometry: false, outFields: ["*"] }) .then(function(featureSet) { // open popup of query result view.popup.open({ location: mapPoint, features: featureSet.features, featureMenuOpen: true }); }); } // end queryFeatures_EFD_HOU() }); </script> </head> <body> <div id="viewDiv"></div> </body> </html>
... View more
01-23-2020
12:12 PM
|
0
|
3
|
2221
|
POST
|
Ken, Thank you very much for your quick help. I'm new to the javascript api (and javascript) so I thought there was some special reason for the function being declared as a variable. Thank you for clearing that up. It's gone now. I added the lines you suggested and the objects came back undefined. console.log("feature type = " + feature.graphic.geometry.type); // ERROR: Unable to get property 'type' of undefined or null reference console.log("centroid x " + feature.graphic.geometry.centroid.x); // ERROR: Unable to get property 'centroid' of undefined or null reference console.log("extent center x = " + feature.graphic.geometry.extent.center.x); // ERROR: Unable to get property 'extent' of undefined or null reference When I check the type, I it looks like the geometry object is undefined. Since these same lines work in the ESRI sample app, I'm confused about the problem with the feature returned in my app. I can get values for all of the feature attributes (including shape.area and shape.len) but nothing about the geometry. The declaration of my FeatureLayer is simple. let IAH_Elev_FLayer = new FeatureLayer({ url: "http://10.88.22.95:6080/arcgis/rest/services/HAS/HAS_wm/MapServer/7", outFields: ["*"] }); IAH_Elev_FLayer.visible = false; I don't see any properties to set about returning geometry or not. Can you think of something else that I might try? Thanks, Bill
... View more
01-23-2020
10:50 AM
|
0
|
5
|
2221
|
POST
|
This is a javascript api app with custom content for the popupTemplate. A custom function is used to build the content. When the function is called, by default, the selected feature is passed in. In this case, it is a polygon. Finding normal map service attributes is no problem. For these I'm able to use both of the following calls. feature.graphic.attributes.GL // works fine feature.graphic.getAttribute("GL")); // works fine Problem: I'm trying to get the x,y of the centroid of the selected feature, in map units. It seems that everything having to do with geometry of this feature is undefined. Using ArcGIS javascript api 4.13 My app is based on this esri sample https://developers.arcgis.com/javascript/latest/sample-code/popuptemplate-function/index.html Thanks, Bill Here's my code that doesn't return x,y let buildPopupContent; // fn used later to build popup content. let popupTemplate = { title: "Airport Tier: {Tier}", content: buildPopupContent }; // When the feature is clicked, this function is called. The feature is passed into the function. function buildPopupContent (feature) { let poly = feature.graphic.geometry; alert("x " + poly.centroid.x); // undefined }; var centerPoint = feature.graphic.geometry.getExtent().getCenter(); // Unable to get property 'getExtent' of undefined or null reference alert("x " + centerPoint.x); }; popuptemplate, centroid, #custom issue
... View more
01-23-2020
07:38 AM
|
0
|
9
|
2459
|
Title | Kudos | Posted |
---|---|---|
1 | 09-07-2021 09:47 AM | |
1 | 08-07-2018 07:04 AM | |
2 | 05-08-2020 08:26 AM | |
1 | 05-07-2020 01:11 PM |
Online Status |
Offline
|
Date Last Visited |
09-15-2021
01:20 PM
|