POST
|
I would assume that the problem is you're giving the sum built-in function a single number when it expects a collection of numbers. 2. Built-in Functions — Python 3.7.0 documentation sum ( iterable [ , start ] ) https://docs.python.org/3/library/functions.html#sum Sums start and the items of an iterable from left to right and returns the total. start defaults to 0 . The iterable’s items are normally numbers, and the start value is not allowed to be a string. Are your values Qs and Ls single float values or are they a collection of numbers?
... View more
08-10-2018
09:24 AM
|
2
|
1
|
23
|
POST
|
Hi Samuel, I do apologize for dragging this out, but I still don't quite understand how the emit would not work. If you have time I'd be more than happy to have you log a support ticket and we can discuss this in more specifics. I wrote up a sample at http://jsbin.com/tuniwel/1/edit?js,output to test out my logic. Below is the relevant JS code. var url = " https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Landscape_Trees/FeatureServer/0 " ; require ( [ "esri/map" , "esri/layers/FeatureLayer" , "dojo/domReady!" ] , function ( Map , FeatureLayer ) { // Create a map var map = new Map ( "map" , { basemap : "hybrid" , center : [ - 82.44109 , 35.6122 ] , zoom : 17 } ) ; // Create a layer object var layer = new FeatureLayer ( url ) ; /* I'm using the timeout to force the issue to occur. The application will wait 3 seconds before wiring in the load event. This will cause the load event to never fire. */ setTimeout ( function ( ) { var msg = "using load event." ; // Wire into the load event. layer . on ( "load" , function ( ) { alert ( "Layer has loaded " + msg ) ; } ) ; // Check if the layer has loaded. /* If this is still false then we're certain that the event was wired before the layer finished loading and we can wait for it to fire naturally. */ if ( ! layer . loaded ) { alert ( "Waiting on load event to fire" ) ; } /* On the other hand, if this is true then assume that the load event was wired after the layer has already loaded. In this case we can force the load event to fire. */ else { alert ( "Layer was loaded before we could finish wiring event." ) ; msg = "using emit to force load event." ; // Force the load event to fire layer . emit ( "load" , { "layer" : layer } ) ; } } , 3000 ) ; map . addLayer ( layer ) ; } ) ; You should note that if I specify 3000 on line 56 that 1) the layer loads before I can wire into the the load event and 2) the code is able to use emit to force the load event to fire. You should also note that if you change line 56 to zero that the load event fires as we would normally expect. Would you be able to modify this so that we unable to get the load event to fire? If you can then I would be able to easily display this issue to our developers so that we determine how to address this issue. I do understand that at the moment you're committed to using version 3.x of the JavaScript API. Although it's a moot point, I do feel that promises would resolve this issue in 4.x as they would implement what you're wanting to add to the FeatureLayer class in 3.x.
... View more
05-03-2018
02:51 PM
|
0
|
0
|
156
|
POST
|
Hi Samuel, I do know that depending on the browser it is possible for the layer to load as soon as it's constructed, but I rarely run into this situation. My goal is to help you to be able to move forward with the use of the 3.x API. Within the documentation it does mention this scenario against DynamicMapServicesLayers, but I'm curious if you ever implement this in your workflow. Below is the documentation I'm referring to and you'll see that an emit was used to resolve this issue in the event that the layer loads faster than you're able to wire in the event. ArcGIS API for JavaScript- Working with Events https://developers.arcgis.com/javascript/3/jshelp/inside_events.html In Internet Explorer, due to resource caching, the onLoad event is fired as soon as the layer is constructed. Consequently you should check whether the layer's loaded property is true before registering a listener for the "load" event: on example: require ([ "esri/layers/ArcGISDynamicMapServiceLayer" , ... ], function ( ArcGISDynamicMapServiceLayer , ... ) { var layer = new ArcGISDynamicMapServiceLayer (...); if ( layer . loaded ){ printInitialExtent ({ "layer" : layer }); } else { layer . on ( "load" , printInitialExtent ); } function printInitialExtent ( evt ) { console . log ( evt . layer . initialExtent ); } }); However, on has a companion function, emit . Instead of directly calling the event handler, we could have forced the event to fire using emit : on example: require ([ "esri/layers/ArcGISDynamicMapServiceLayer" , ... ], function ( ArcGISDynamicMapServiceLayer , ... ) { var layer = new ArcGISDynamicMapServiceLayer (...); layer . on ( "load" , printInitialExtent ); if ( layer . loaded ){ layer . emit ( "load" ,{ "layer" : layer }); } function printInitialExtent ( evt ) { console . log ( evt . layer . initialExtent ); }
... View more
05-03-2018
12:30 PM
|
1
|
2
|
291
|
POST
|
Hi Samuel, Are you able to replicate a situation where the FeatureLayer loads before the next line of code can execute to wire into the load event? If so would you be able to record a video of that and send it to me? I'd be very interested in replicating this if possible.
... View more
05-02-2018
02:57 PM
|
0
|
4
|
291
|
POST
|
Have you tried either creating a layer from the selected features or applying a definition query to the layer to display a subset of features? Working with selected features http://desktop.arcgis.com/en/arcmap/latest/map/working-with-layers/working-with-selected-features.htm#ESRI_SECTION1_EA781C8D98E54C81A68DA4FAC7B98B7F Displaying a subset of features in a layer http://desktop.arcgis.com/en/arcmap/latest/map/working-with-layers/displaying-a-subset-of-features-in-a-layer.htm
... View more
03-21-2018
07:19 AM
|
1
|
1
|
554
|
POST
|
Hi Surendran Neelakantan, As per our phone conversation earlier, we implemented the following to resolve this issue. import arcpy import pythonaddins class cbxClass1 ( object ) : """Implementation for ComboBoxExample_addin.cbx1 (ComboBox)""" def __init__ ( self ) : self . items = [ chr ( n ) * 3 for n in range ( 65 , 65 + 3 ) ] # [AAA, BBB, CCC] self . editable = True self . enabled = True self . dropdownWidth = 'WWWWWW' self . width = 'WWWWWW' cbxClass1 . _hook = self def onSelChange ( self , selection ) : cbxClass2 . _hook . items . extend ( [ selection ] ) class cbxClass2 ( object ) : """Implementation for ComboBoxExample_addin.cbx2 (ComboBox)""" def __init__ ( self ) : self . items = [ chr ( n ) * 4 for n in range ( 90 , 90 - 3 , - 1 ) ] # [ZZZ, XXX, YYY] self . editable = True self . enabled = True self . dropdownWidth = 'WWWWWW' self . width = 'WWWWWW' cbxClass2 . _hook = self def onSelChange ( self , selection ) : cbxClass1 . _hook . items . extend ( [ selection ] ) As I stated on our call, there will be more than way to accomplish this. I will ensure that this approach is documentation on a public facing knowledge article. I will also pass this information along to the necessary parties to determine how we can better explain this workflow within our documentation. Please let me know if you have any problems with this. Freddie G.
... View more
02-09-2018
09:06 AM
|
1
|
1
|
55
|
POST
|
I would assume that you were using the out-of-the-box Buffer (Analysis) tool within ArcObjects to create the one-side buffer. Buffer (Analysis) http://desktop.arcgis.com/en/arcmap/latest/tools/analysis-toolbox/buffer.htm In the above documentation for the tool you'll see that it line side parameter allows you to specify the side of the feature that will be buffered. Within the JS API there is no functionality available to the client that would allow this out-of-the-box. The suggested workflow to implement this would be to do one of the following: 1. Publish the Buffer (Analysis) tool as a Geoprocessing Service. You could then supply your features to this service along with the buffer side and the out-of-the-box GP tool would handle returning you the results you're seeking. 2. Implement logic in the JS API to cut the buffer returned by the client (i.e. when using GeometryEngine to buffer) or a service, such as using GeometryService to buffer. In regards to the second suggestion, we do not have an example of this and I cannot write one for you, but I can provide you with enough logic to implement this on your end. For example, let's say that you were buffering a straight line as shown below. geometryEngine buffer Method https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.geometryengine-amd.html#buffer To get top half of this buffer I would start by first creating a line that bisects the buffer polygon. This could done in several ways depending on the API. In a simple case like shown above I could either move the x coordinate of the vertices or I could leverage the envelope of the geometry and extend the lines to them as shown below. Polygon getExtent Method https://developers.arcgis.com/javascript/3/jsapi/polygon-amd.html#getextent geometryEngine nearestCoordinate Method https://developers.arcgis.com/javascript/3/jsapi/esri.geometry.geometryengine-amd.html#nearestcoordinate Polyline insertPoint Method https://developers.arcgis.com/javascript/3/jsapi/polyline-amd.html#insertpoint Now that I have a line that bisects the polygon I could use the cut method of the geometryEngine to cut the polygon into left and right halves. I would then need to decide on which halve to persist and whether I want to replace the existing geometry or insert the data as a new record into my GraphicsLayer or FeatureLayer. Now as I stated before, I cannot implement the code for the second suggestion above. It would be your responsibility to handle the logic for this task. You'll also want to note that the workflow I describe was intended for situations where the line is straight in a cardinal direction. This will not be the case with most real world data and you will find situations where the lines are curved or at angles. You'll need to ensure that you logic takes these situations into account when creating the line to cut the polygon. I'll leave you with the last set of examples. After reviewing my suggested workflow thing about how you'd handle the following programmatically to determine the top and bottom halves of the polygon.
... View more
04-14-2017
11:08 AM
|
3
|
1
|
304
|
POST
|
Take a look at the example I sent in my previous message. Your problem is that you need to provide the 3rd parameter as a feature class or a geometry object. By default the da cursor will return geometry as a tuple. You will want to use the Shape@ token to have it return the geometry object. Just to provide a little more detail I've also included my logic below. # Example 1 geom = next ( arcpy . da . SearchCursor ( "fnet" , "SHAPE" ) ) [ 0 ] arcpy . management . SelectLayerByLocation ( "fnet" , "INTERSECT" , geom ) ''' In the above example "SHAPE" returns (2124.3204345703125, 3.0001017252604063) ''' # Example 2 geom = next ( arcpy . da . SearchCursor ( "fnet" , "SHAPE@XY" ) ) [ 0 ] arcpy . management . SelectLayerByLocation ( "fnet" , "INTERSECT" , geom ) ''' In the above example "SHAPE@XY" returns (2124.3204345703125, 3.0001017252604063) ''' # Example 3 geom = next ( arcpy . da . SearchCursor ( "fnet" , "SHAPE@" ) ) [ 0 ] arcpy . management . SelectLayerByLocation ( "fnet" , "INTERSECT" , geom ) ''' In the above example "SHAPE@" returns <Polygon object at 0x2382fcf0[0x2382f3e0]> ''' In the above examples note what is returned from the cursor. If you were to run each of these expressions you'd not that only the third one works, whereas the first two return the following exception. Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.4\arcpy\arcpy\management.py", line 7320, in SelectLayerByLocation raise e RuntimeError: Object: Error in executing tool
... View more
09-30-2016
06:31 AM
|
2
|
0
|
51
|
POST
|
Take a look at the parameters for the tool. Select Layer By Location http://desktop.arcgis.com/en/arcmap/latest/tools/data-management-toolbox/select-layer-by-location.htm Note that the second parameter is "overlap_type" (e.g. INTERSECT, CONTAINS, etc.) and you're supplying row[1], which is a tuple representation of the geometry with the value (-9645043.375313655, 3833831.999483527).
... View more
09-30-2016
06:11 AM
|
1
|
0
|
51
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|