POST
|
Thanks. Unfortunately, my agency mandates ADA compliance and ExB is not there yet. That's why I focus on calcite with ArcGIS JS API, no templates.
... View more
06-30-2022
09:17 AM
|
0
|
0
|
861
|
POST
|
I'm trying to auto populate a text box in a widget I have created. I would like to be able to start typing a route and it returns the lists of routes as you type. I don't need to know how to pass this object as I already have that working. I found this post and tried to implement it in my application with not much success.. https://community.esri.com/people/mlewis22/blog/2014/10/21/autocomplete-search-box-using-arcgis-services I was wondering if anyone else as has done this in a widget.js file? Here is what my code currently looks like. Any direction would be greatly appreciated. _queryRoutes: function (Query, QueryTask) {
//create array
var array = []
//build query task
var queryTask = new QueryTask("https://app.mdt.mt.gov/arcgis/rest/services/LRS/LRM_RM/MapServer/0");
//build query filter
var query = new Query();
query.returnGeometry = false;
query.outFields = ["corridor"];
query.where = "OBJECTID > 0";
queryTask.execute(query, showResults);
function showResults(results) {
// Collect the results
var resultItems = [];
var resultCount = results.features.length;
for (var i = 0; i < resultCount; i++) {
var featureAttributes = results.features[i].attributes;
for (var attr in featureAttributes) {
var routes = String(featureAttributes[attr]);
resultItems.push(routes);
}
}
// Sort the array
var sorted = resultItems.sort()
// Remove Duplicates
var uniqueNames = [];
$.each(sorted, function (i,el) {
if ($.inArray(el, uniqueNames) === -1) {
uniqueNames.push(el);
}
});
array = uniqueNames
var availableTags = array;
$("#routes").autocomplete({
// set the source as the availableTags above
source: availableTags
});
}
}, I was able to create this html file but not sure how to incorporate it into my custom widget. <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no" /> <link rel="stylesheet" href="https://js.arcgis.com/3.20/js/esri/css/esri.css"> <link rel="stylesheet" href="https://code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css"> <script src="https://code.jquery.com/jquery-1.10.2.js"></script> <script src="https://code.jquery.com/ui/1.11.1/jquery-ui.js"></script> <link rel="stylesheet" href="https://community.esri.com/resources/demos/style.css"> <style> html, body, body { background-color: #FFF; overflow: hidden; font-family: "Trebuchet MS"; } </style> <script src="https://js.arcgis.com/3.20/"></script> <script> require(["esri/map", "esri/tasks/QueryTask","esri/tasks/query", "dojo/domReady!"], function (Map, QueryTask, Query) { $(function () { var array = [] queryTask = new QueryTask("https://app.mdt.mt.gov/arcgis/rest/services/LRS/LRM_RM/MapServer/0"); query = new Query(); query.returnGeometry = false; query.outFields = ["Corridor"]; query.where = "OBJECTID > 0"; queryTask.execute(query, showResults); function showResults(results) { // Collect the results var resultItems = []; var resultCount = results.features.length; for (var i = 0; i < resultCount; i++) { var featureAttributes = results.features.attributes; for (var attr in featureAttributes) { // Convert the attribute to a string. Null Values create an extra comma which stops the widget from functioning. routes = String(featureAttributes[attr]); // push the attributes tothe blank array resultItems.push(routes); } } // Sort the array sorted = resultItems.sort() // Remove Duplicates var uniqueNames = []; $.each(sorted, function (i, el) { if ($.inArray(el, uniqueNames) === -1) uniqueNames.push(el); }); // Set the varrible array array = uniqueNames // This is your AutoComplete Widget var availableTags = array; // Reference the div id which you want the autocomplete list to appear (in this case tag) $("#routes").autocomplete({ // set the source as the availble tags above source: availableTags }); } }); }); </script> </head> <body> <div class="ui-widget"> <label for="routes">Corridor: </label> <input id="routes"> </div> </body> </html> I figured it out. Needed to have the following libraries loaded in the index.html file. <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js" ></script>
... View more
05-02-2019
11:20 AM
|
0
|
0
|
1011
|
POST
|
Your route system should be based upon your segments..... So if there is a discrepancy then either one layer is "Wrong" or the two are not related to each other. Without knowing the specifics, my suggestion is to create a Route system based upon your "segmented" layer using the same route name on the segments. You can use the option to accumulated lengths of each segment. The final result would be your own route layer upon which you can event map based upon accumulated mileage that would agree with the segmented on (because you built the layer based upon it) Generally speaking you should only have one "Route". This will be a measured feature aka (contains the cumulative mileage). In my case I deal with roads. I have only one "Route" for any particular road. Generally it starts at a 0 point (not always) and accumulates measures to its end point. Now if I want and particular "milepost" I can simply event map any point against the "Route" feature. If I want a line segment, I event map the beg and end points against the route for the line segment. Now I understand that sometime there is a need to have multiple routes definitions. I employ actually 3. The primary route feature is defined by the Dual Centerines of each road, On roads going in opposite directions "aka divided highway". In addition we employ a single centerline representation as well as a straight line diagram representation. Although we have 3 route system, they are very carefully designed all based upon our primary definition. All Intersection, cumulative mileages are all exactly the same and agree with each other. The route name is carefully designed for example take State Route 836 -- In our primary route system its name is 83600000E or 83600000W its length is 36 miles. In the Single Centline LRS (Linear Referencing System) aka "Route" layer, the same route is named 83600000CL its length is 36 miles. For out Single Line diagram it is a straight line that is exactly 12 inches long that we create a route of 36 miles on it. Its route name is the same as single centerline. No matter what route layer I use or "Mix Match" I have strict rules that apply -- for names and length. So when I mix & match knowing the Lengths all match for each route all I have to do is programatically deal with the route name differences. Example -- Project Engineer gives me some points from his plans -- engineering plans are based off of single centerline. -- Finance want quantities and representation based upon google maps imagery -- (Dual Centerline). All I do is create, being a VB guy is create a simple script changing the single line name to the double and iterate for both directions.... EB = Left(Single Centerline Name,8) & "EB" and similarly the same for the WB side. Then event map it against our Primary route system Sorry about the wall of text but it appears you have two LRS systems that are defined much differently and you are trying to use them together. That cannot really happen unless you define yet another blending the rules for both. My suggestion is to use one for your analysis. If the "segmented" one is more accurate for uses then combine all the segments together under one route name.... What is linear referencing?—Help | ArcGIS for Desktop https://magtug.files.wordpress.com/2011/11/2007-09_linear_referencing_in_arcgis_enterprise_deployments-x.pdf
... View more
04-19-2019
07:35 AM
|
2
|
0
|
701
|
POST
|
Instead of precondition, I suggest setting up script tool input and output parameters like this table = arcpy.GetParameterAsText(0) # parameter 0: input table (Table View)
arcpy.SetParameterAsText(1, True) # parameter 1: result (Boolean) Setting script tool parameters—Help | ArcGIS Desktop Then connect the combine table (data element in your model) to the script tool, and connect the script tool output to the Make Route Event Layer tool as a precondition. That should do it. BTW, you need to format Python code for it to be readable here: /blogs/dan_patterson/2016/08/14/script-formatting?sr=search&searchId=a6efc0d2-08b3-4930-b012-97b3576ea848&searchIndex=4 Another approach: For a short bit if python snippet like this you can also use the Calculate Value tool and write a python function for your code, this can save you from the hassle of a separate script tool, passing parameters as text, and all that jazz. # Calculate Value expression
proc(r"%combine%") # set combine as precondition to this CV tool
# Calculate Value code block
def proc(combine):
ridList = []
with arcpy.da.SearchCursor(table, ["RID"]) as cursor:
for row in cursor:
ridList.append(row[0])
del cursor
ridList = set(ridList)
for RID in ridList:
toMeasList = []
with arcpy.da.SearchCursor(table, ["RID", "END"], "RID = '{}'".format(RID)) as cursor:
for row in cursor:
toMeasList.append(row[1])
del cursor
toMeasList.sort()
with arcpy.da.UpdateCursor(table, ["END"], "RID = '{}'".format(RID)) as cursor:
for row in cursor:
row[0] = toMeasList[-1]
cursor.updateRow(row)
del cursor
toMeasList.sort()
with arcpy.da.UpdateCursor(table, ["OBJECTID"]) as cursor:
for row in cursor:
if row[0] == 2:
cursor.deleteRow()
del cursor
return True # data type: Boolean (use as precondition)
... View more
03-05-2019
03:10 PM
|
1
|
0
|
299
|
POST
|
I have the following function and when it's executed it returns SEE URL Below (A). My GP service returns SEE below (B) I'm thinking when the url that gets built and passed to the GP service it has the "geometryType":null at the end its causing the GP service to fail. Does anyone know why the "geometryType":null is added to the end of the url? I looked at the API and tried adding "env:outSR":102100 to my var params but that didn't help. //execute gp
executeGP: function (rs) {
this.shelter.show();
this.map.graphics.clear();
var featureSet = new FeatureSet();
var gra = new Graphic(null, null, rs, null);
featureSet.features = [gra];
featureSet.fields = [
{
name: "OBJECTID",
alias: "OBJECTID",
type: "esriFieldTypeOID"
}, {
//name: "Corridor",
name: "Corridor",
alias: "Corridor",
type: "esriFieldTypeString",
length: 8
}, {
name: "from_offset",
alias: "from_offset",
type: "esriFieldTypeSingle"
}, {
name: "to_offset",
alias: "to_offset",
type: "esriFieldTypeSingle"
}
];
var params = {
"Route_Points": featureSet,
};
this.gp.submitJob(params, lang.hitch(this, this.processGP));
},
(A) Returns the following url. :https://app.mdt.mt.gov/arcgis/rest/services/LRS/ReturnRouteSegment/GPServer/segment/submitJob?f=json&env:outSR=102100&Route_Points={"fields":[{"name":"OBJECTID","alias":"OBJECTID","type":"esriFieldTypeOID"},{"name":"Corridor","alias":"Corridor","type":"esriFieldTypeString","length":8},{"name":"from_offset","alias":"from_offset","type":"esriFieldTypeSingle"},{"name":"to_offset","alias":"to_offset","type":"esriFieldTypeSingle"}],"features":[{"attributes":{"OBJECTID":1,"Corridor":"C000001E","from_offset":"100","to_offset":"200"}}],"geometryType":null}
({
"paramName": "Route_Points_Events1",
"dataType": "GPFeatureRecordSetLayer",
"value": {
"displayFieldName": "",
"geometryType": "esriGeometryPolyline",
"spatialReference": {
"wkid": 102100,
"latestWkid": 3857
},
"fields": [
{
"name": "OBJECTID",
"type": "esriFieldTypeOID",
"alias": "OBJECTID"
},
{
"name": "Corridor",
"type": "esriFieldTypeString",
"alias": "Corridor",
"length": 8
},
{
"name": "from_offset",
"type": "esriFieldTypeSingle",
"alias": "from_offset"
},
{
"name": "to_offset",
"type": "esriFieldTypeSingle",
"alias": "to_offset"
},
{
"name": "LOC_ERROR",
"type": "esriFieldTypeString",
"alias": "LOC_ERROR",
"length": 50
},
{
"name": "Shape_Length",
"type": "esriFieldTypeDouble",
"alias": "Shape_Length"
}
],
"features": [{
"attributes": {
"OBJECTID": 1,
"Corridor": "C000001E",
"from_offset": 100,
"to_offset": 200,
"LOC_ERROR": "NO ERROR",
"Shape_Length": 241333.05456719542
},
"geometry": {"paths": [[
[
-1.2763657977400001E7,
6122093.660400003B)
]
]]}
}],
"exceededTransferLimit": false
}
}
... View more
01-05-2018
11:38 AM
|
0
|
0
|
1836
|
POST
|
Terry, In that case then you can simply add the Basemap Gallery Widget and when configuring the widget click the remove button in the upper right corner of the basemaps you do not want and once you save the app the ones you left will be the only ones available in the widget.
... View more
12-16-2015
08:23 AM
|
2
|
0
|
295
|
POST
|
This is a screen capture of what happens when I click on the help for the widget..
... View more
11-05-2015
01:29 PM
|
0
|
0
|
204
|
POST
|
I really do not have an understanding of what you are trying to do with your script. I'd suggest you strip out as much as possible, simplifying things down to bare necessities that accomplishes a portion or a simplified version of what you expect. Then build upon what you learn from that.
... View more
10-30-2015
05:18 AM
|
0
|
0
|
103
|
POST
|
are you running python using arcmap's ide or something else external, like pythonwin, pyscripter etc etc? If internal...Using the Results window—Help | ArcGIS for Desktop or if you have errors with arctoolbox tools as well
... View more
10-28-2015
01:06 PM
|
1
|
0
|
473
|
POST
|
I'm wondering if you can manually edit data paths for a geoprocessing service that is running on your Arcserver that is on Linux? I have a model that I have created that works when I run it in ArcMap unless I set the final segment as an output parameter. The final tool in the model is a make route event layer. The problem is the event points file is in memory. I have tried to export the model to a python script and set the parameter and point the points file to in_memory location but when I create the tool from the python script and run it, it just errors out. I'm trying to find another option to get this thing to work. TIA for any help or direction
... View more
10-27-2015
07:05 AM
|
0
|
0
|
2129
|
POST
|
seems to clear memory now but still get this error.. The type of out_event_properties does not match the type of in_features.
... View more
10-27-2015
09:21 AM
|
0
|
0
|
1753
|
POST
|
I exported the model to python and this is the code. I would have thought there would be a local variable for the points_Events # -*- coding: utf-8 -*-
# ---------------------------------------------------------------------------
# seg.py
# Created on: 2015-10-22 10:41:12.00000
# (generated by ArcGIS/ModelBuilder)
# Usage: seg <first_point> <end_point> <merge__3_> <points> <points_Events>
# Description:
# ---------------------------------------------------------------------------
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("E:/MDTAPPS/terry/ref segment.tbx")
# Script arguments
first_point = arcpy.GetParameterAsText(0)
if first_point == '#' or not first_point:
first_point = "E:\\MDTAPPS\\terry\\Default.gdb\\first_point" # provide a default value if unspecified
end_point = arcpy.GetParameterAsText(1)
if end_point == '#' or not end_point:
end_point = "E:\\MDTAPPS\\terry\\Default.gdb\\end_point" # provide a default value if unspecified
merge__3_ = arcpy.GetParameterAsText(2)
if merge__3_ == '#' or not merge__3_:
merge__3_ = "E:\\MDTAPPS\\terry\\Default.gdb\\merge" # provide a default value if unspecified
points = arcpy.GetParameterAsText(3)
if points == '#' or not points:
points = "E:\\MDTAPPS\\terry\\Default.gdb\\points" # provide a default value if unspecified
points_Events = arcpy.GetParameterAsText(4)
if points_Events == '#' or not points_Events:
points_Events = "points Events3" # provide a default value if unspecified
# Local variables:
first_point__2_ = first_point
first_point_Event = first_point__2_
first_point_ev = first_point_Event
Output_Event_Table_Properties = first_point_Event
end_point__2_ = end_point
end_point_Event = end_point__2_
end_point_ev = end_point_Event
end_point_ev_View = end_point_ev
Output_Event_Table_Properties__2_ = end_point_Event
MDTGIS_ROUTES_LRM_RM = "MDTGIS.ROUTES_LRM_RM"
MDTGIS_ROUTES_LRM_DC_MI = "MDTGIS.ROUTES_LRM_DC_MI"
MDTGIS_ROUTES_LRM_DC_MI__2_ = "MDTGIS.ROUTES_LRM_DC_MI"
Default_gdb = "E:\\MDTAPPS\\terry\\Default.gdb"
MDTGIS_ROUTES_LRM_DC_MI__3_ = "MDTGIS.ROUTES_LRM_DC_MI"
# Process: Calculate Field
arcpy.CalculateField_management(first_point, "Corridor", "str(!Corridor!) + \"_\" + str(!RM!)", "PYTHON_9.3", "")
# Process: Make Route Event Layer
arcpy.MakeRouteEventLayer_lr(MDTGIS_ROUTES_LRM_RM, "ROUTE_ID", first_point__2_, "Corridor POINT beg_offset", first_point_Event, "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
# Process: Locate Features Along Routes
arcpy.LocateFeaturesAlongRoutes_lr(first_point_Event, MDTGIS_ROUTES_LRM_DC_MI, "CORRIDOR", "0 Meters", first_point_ev, Output_Event_Table_Properties, "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
# Process: Calculate Field (2)
arcpy.CalculateField_management(end_point, "Corridor", "str(!Corridor!) + \"_\" + str(!RM!)", "PYTHON_9.3", "")
# Process: Make Route Event Layer (2)
arcpy.MakeRouteEventLayer_lr(MDTGIS_ROUTES_LRM_RM, "ROUTE_ID", end_point__2_, "Corridor POINT end_offset", end_point_Event, "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
# Process: Locate Features Along Routes (2)
arcpy.LocateFeaturesAlongRoutes_lr(end_point_Event, MDTGIS_ROUTES_LRM_DC_MI__2_, "CORRIDOR", "0 Meters", end_point_ev, Output_Event_Table_Properties__2_, "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")
# Process: Make Table View
arcpy.MakeTableView_management(end_point_ev, end_point_ev_View, "", "", "OBJECTID OBJECTID VISIBLE NONE;RID RID VISIBLE NONE;to_MEAS to_MEAS VISIBLE NONE;Distance Distance VISIBLE NONE;RM RM VISIBLE NONE")
# Process: Merge
arcpy.Merge_management("E:\\MDTAPPS\\terry\\Default.gdb\\first_point_ev;end_point_ev_View", merge__3_, "RID \"CORRIDOR\" true true false 10 Text 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\first_point_ev,RID,-1,-1,end_point_ev_View,RID,-1,-1;from_MEAS \"from_MEAS\" true true false 0 Double 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\first_point_ev,from_MEAS,-1,-1;to_MEAS \"to_MEAS\" true true false 0 Double 0 0 ,First,#,end_point_ev_View,to_MEAS,-1,-1")
# Process: Table to Table
arcpy.TableToTable_conversion(merge__3_, Default_gdb, "points", "", "RID \"CORRIDOR\" true true false 10 Text 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\merge,RID,-1,-1;from_MEAS \"from_MEAS\" true true false 0 Double 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\merge,from_MEAS,-1,-1;to_MEAS \"to_MEAS\" true true false 0 Double 0 0 ,First,#,E:\\MDTAPPS\\terry\\Default.gdb\\merge,to_MEAS,-1,-1", "")
# Process: Make Route Event Layer (3)
arcpy.MakeRouteEventLayer_lr(MDTGIS_ROUTES_LRM_DC_MI__3_, "CORRIDOR", points, "rid LINE from_MEAS to_MEAS", points_Events, "", "ERROR_FIELD", "NO_ANGLE_FIELD", "NORMAL", "ANGLE", "LEFT", "POINT")
# Process: Script1
arcpy.gp.toolbox = "E:/MDTAPPS/terry/ref segment.tbx";
# Warning: the toolbox E:/MDTAPPS/terry/ref segment.tbx DOES NOT have an alias.
# Please assign this toolbox an alias to avoid tool name collisions
# And replace arcpy.gp.Script1(...) with arcpy.Script1_ALIAS(...)
arcpy.gp.Script1()
... View more
10-22-2015
09:45 AM
|
0
|
0
|
481
|
POST
|
See the reply at the thread below: Populate fields using python
... View more
10-14-2015
06:39 AM
|
1
|
0
|
217
|
Title | Kudos | Posted |
---|---|---|
1 | 03-10-2016 08:36 AM | |
1 | 03-10-2016 09:00 AM | |
1 | 07-16-2015 01:15 PM | |
1 | 08-19-2015 02:57 PM | |
1 | 09-14-2015 06:48 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:25 AM
|