POST
|
So far the ways I have done it is clunky and create a lot of hassles when I get a new version of ExB. I'm redoing our repo to check in at the project level (one level up from client and server), is there a way to merge new ExB in the existing branch once I get the new ExB?
... View more
11-16-2022
08:51 AM
|
0
|
0
|
304
|
POST
|
I'm new to writing unit tests and try to get some inspirations from "show-unit-tests" from the SDK, but "Query Features" is not working for me, and would like your input on both the syntax and conceptual design of the test. I have created a custom map widget that access coordinates from another widget and draw a point (graphic in graphic layer) on the map. The coordinates in the other widgets are passed in with code: this.props.dispatch(appActions.widgetStatePropChange(this.props.id, 'X', value)) this.props.dispatch(appActions.widgetStatePropChange(this.props.id, 'Y', value)) The coordinates are also shown as text above the map in the format of: "X: <value> Y: <value>" I am thinking for the unit test to be valuable, I should: 1) test the access from widgetsState mock 2 values and try to access them, then assert their values? 2) test the API: continue from #1, make a graphic in graphic layer, then ??? import { React, getAppStore, appActions } from 'jimu-core'
import _Widget from '../src/runtime/widget'
import { widgetRender, wrapWidget, getInitState, getDefaultAppConfig } from 'jimu-for-test'
const render = widgetRender()
jest.mock('jimu-core', () => {
return {
...jest.requireActual('jimu-core'),
loadArcGISJSAPIModule: jest.fn().mockImplementation(moduleId => {
let module
if (moduleId === 'esri/layers/GraphicLayer') {
module = jest.fn().mockImplementation(() => {
return {
//not sure what goes in here
}
})
}
return Promise.resolve(module)
})
}
})
describe('test map-view widget', () => {
it('test label, map from state', () => {
const Widget = wrapWidget(_Widget, { config: {} })
getAppStore().dispatch(appActions.updateStoreState(getInitState().merge({
appConfig: getDefaultAppConfig().merge({
widgets: {
w1: {
label: 123 // not working
}
}
})
})))
const renderResult = render(<Widget widgetId="w1" />)
expect(renderResult.queryByText('123')).toBeInTheDocument()
})
it('test api', async () => {
const { findByText } = render(<Widget widgetId="w2" />)
// Not sure what goes in here
})
})
... View more
09-28-2022
04:09 PM
|
1
|
1
|
393
|
POST
|
I'm looking to make a custom form with a submit button, where it would retrieve a location from an api and show the coordinates on a map. 1. I'm not finding a form element under https://developers.arcgis.com/experience-builder/storybook/, not sure how I should go about setting one up? 2. The examples I've been finding on forms for React are all based on app, not the widget. I'm not sure where the custom hook that gets called after user click on the submit button should go in the widget, or does it not? If you have an example that will be great. 3. Will the form be one widget and the map be another widget?
... View more
07-27-2022
06:04 PM
|
0
|
0
|
419
|
POST
|
We have some items (feature layers, apps that depend on the feature layers) that we need to be shared with Everyone in our organization, but we lately noticed a problem that our custom role "data managers" can edit item details or even take ownership on these items. The original intention was for them to have these permissions for the items in their groups. Without changing the items' share status, is there a way to limit this role's power over items shared with Everyone? If not, this would be desired feature for the future release of Portal. arcigs portal
... View more
06-03-2020
02:58 PM
|
0
|
0
|
338
|
POST
|
What version of Python interpreter are you using? I had this error when I was trying to manipulate some dataset, but the problem went away once I switched from 32 bit interpreter to 64 bit interpreter.
... View more
07-07-2016
01:55 PM
|
0
|
1
|
944
|
POST
|
About Personal ArcSDE (also called "Desktop Geodatabase" or "ArcSDE Personal Server" in some documents by ESRI): I fully agree this is badly documented, but on the other hand, once you realize there is actually no real distinction between Personal, Workgroup, and Enterprise Geodatabases, except a licensing scheme determining the maximum no. of concurrent users for the geodatabase (Vince may protest here, but for the sake of this thread, I think it valid), it actually turns out to be surprisingly simple: *** STEPS TO INSTALL "PERSONAL ARCSDE / DESKTOP GEODATABASE" *** (E.g. with "ArcGIS for Home Use" license based on "ArcGIS for Desktop Advanced") * EDIT: * It may be advisable to reboot in between / after some of these steps, e.g. installing SQL Server, so as to ensure all services are properly running and usable for the next step. 1) - Install SQL Server 2012 Expresss I am not going to detail all steps of the SQL Server installation here, use the Microsoft documentation if in doubt. Basically, you can choose almost all defaults, as the 2012 version of SQL Server installation already sets it all up under restricted Windows accounts, so rather safe. The defaults will install "extra's" like the Reporting Services that aren't necessary for the functioning of an ESRI Geodatabase, so you may prefer to opt out on these "software developer / SDK options" of the installation. NOTE: you can also use the ArcGIS for Desktop 10.2 installation to install SQL Server 2008 R2 Express, as it is included in the desktop installer, but since I guess you will want to use the "latest", install 2012. 2) - Create a new instance in the process of the installation of SQL Server. Record the name of the instance for later use. 3) - Ensure you are logged in as a full Windows Administrator on your PC. This is very important, if you don't do this, the enabling of the database for geodatabase storage may fail. Make sure this administrative login is also registered with your SQL Server Express if you haven't already done so during the install of SQL Server Express (which is usually the case, so you can probably skip this). 4) - Start the ArcGIS for Desktop 10.2 installation. NOTE: Yes, you need the installation for ArcGIS for Desktop, not ArcGIS for Server. So you can use the installation that is part of the 10.2 Desktop Advanced "ArcGIS for Home Use" program. It is downloadable from the Customer Care portal once you receive your license from ESRI. 5) - Once in the main screen, choose ArcSDE for Microsoft SQL Server 2008 R2 Express as the installation option. NOTE: don't worry: it won't automatically overwrite or re-install your SQL Server 2012 Express, see next steps. 6) - Once the install wizard appears, choose Next 7) - In the next dialog that appears (Installation Options), deactivate the Microsoft SQL Server Express Edition option, since you already installed it in step 1). Leave the Enable geodatabase storage on SQL Server Express checked. You want your database to be enabled to use ESRI Geodatabases. 😎 - Click Next 9) - In the Choose a SQL Server Instance and add a Windows login dialog, choose under SQL Server instance name your instance created in step 1), e.g. YOUR_COMPUTER_NAME\YOUR_INSTANCE. Add a valid Windows Login who will administer the geodatabase, e.g. YOUR_COMPUTER_NAME\YOUR_LOGIN_NAME. Note the YOUR_COMPUTER_NAME, since we are using Personal ArcSDE on SQL Server Express, your local PC is likely the server. 10) - Click Next and finish the installation. You can also close the ArcGIS for Desktop installation window now, as you no longer need it. Your database should now be enabled for creating geodatabases 11) - To create a geodatabase, DON'T USE THE "Create / Enable Enterprise Geodatabase" TOOLS!!! I can not emphasize this enough. As the name of the tools already indicates, these tools only work against "enterprise" databases, not on SQL Server Express! 12) - To create an ESRI Geodatabase on SQL Server Express, simply create a new Database Server(!) connection to the SQL Server instance in ArcCatalog using the Add Database Server option under Database Servers in the Catalog Tree of ArcCatalog. NOTE: I wrote Database Server, not Database Connection. You must first create a Database Server connection, as only a Database Server connection contains the context menu option to create a New Geodatabase, as in step 13). 13) - Now right click the new Database Server connection, and choose New Geodatabase from the context menu. Yes, it is that simple! No hassle with an authorization file as in the "Create / Enable Enterprise Geodatabase" tools. The authorization of ArcSDE Personal Server forms an integral part of your ArcGIS for Desktop license, and was applied in steps 4) to 10). NOTE 1: In order for this step to work, you must have an ArcGIS for Desktop Standard or ArcGIS for Desktop Advanced license. This doesn't cost you anything extra with an ArcGIS for Home Use license, it is just another licensing scheme you need to activate / authorize from the ArcGIS Administrator included with ArcGIS for Desktop. In Desktop Basic the New Geodatabase option is disabled in the context menu. NOTE 2: After you have created the geodatabase via the Database Server connection, you can now also use the Add Database Connection option in ArcCatalog, to create a new Database Connection to your geodatabase. Congratulations, you have just created your Personal ArcSDE / Desktop Geodatabase in SQL Server 2012 Express! Hi Marco, I am following your instructions and thank you they have been very helpful. Just a question, I already have ArcGIS for Desktop installed, do I need to uninstall then reinstall to get the option for step 7? Right now, I am able to connect to my instance, but when I use the "new geodatabase" option then I get an error, so I wonder if it has to do with me skipping step 7. My license is "Advanced". [ATTACH=CONFIG]28981[/ATTACH]
... View more
11-09-2013
06:21 AM
|
0
|
0
|
343
|
POST
|
OK, now I am looking for more help to organize these JPGs. Now all the JPGs are in one folder (C:\temp), I want to copy them into different folders based on the field "Wall_Num" (numeric) in a feature class "Result", and rename them based on a field called "JPG" in the same feature class, e.g. "Tree.jpg". The "Result" feature class holds the original name of these photos in a field called "PhotoPath2", e.g. IMG_0070430.jpg. I also have created a table that holds unique values of the all "Wall_Num" values called tbl_Wall_Numbers. My plan was to: 1. Create folders based on the "Wall_Num" in tbl_Wall_Numbers using search cursor (done) 2. Create Query Table with the name "Wallx", with records "Wall_Num" = x (x being "Wall_Num" value) (seem to have worked, no errors, but I could not tell if it executed successfully...also have tried with create feature layer and selectlayerbyattribute) 3. Use search cursor to go through Query Table row by row, and if current filename matches "PhotoPath2", rename it using "JPG" (maybe this is where the problem is, I am trying to use a cursor nested inside another cursor...other ways to do this?) os.rename(file, file.replace("\"[PhotoPath2]\","\"[JPG]\")) 4. Copy the JPG into the correct folder, based on its "Wall_Num" value until all JPGs in temp are copied 5. Repeat 2 - 5 for all "Wall_Num" in tbl_Wall_Numbers. Another question sort of related to this: how do I get rid of the querytable? Once I try to run the same process again, it will say querytable "Wallx" already exists. I have overwriting geoprocessing results turned on. Thank you for pointing me to the correct direction!
... View more
09-19-2011
12:48 PM
|
0
|
0
|
741
|
POST
|
What I want to do is: 1. Create folders based on "Wall_Num" value in "tbl_Wall_Numbers" row by row 2. As each row is selected, use "Wall_Num" value to plug into an SQL expression that select records from a different table "Results" 3. Do something other stuff with the records in "Results" I am able to get the part of creating folders fine, but when I try to pass row.getValue(field.name) into a SQL expression, it just says I have invalid expression. I have tried many different ways to modify it but it doesn't seem to want to work. I am working in ArcGIS 10 and using a file geodatabase. Can this be done? I also have tried to set up another SearchCursor but run into the same invalid SQL expression problem. Thanks! # Import arcpy module import arcpy, os # Import all of arcpy from arcpy import env # Local variables: fc = "Results" WallNum = "tbl_Wall_Numbers" # Change dir os.chdir("C:\Project") # Set the workspace environment env.workspace = "C:\project.gdb" # Use the unique list of wall numbers rows = arcpy.SearchCursor(WallNum) fieldList = arcpy.ListFields(WallNum,"Wall_Num") for row in rows: for field in fieldList: # Create the wall folders os.makedirs("Wall" + str(row.getValue(field.name))) # Query for records in the wall arcpy.MakeFeatureLayer_management(fc, "wall_select") arcpy.SelectLayerByAttribute_management ("wall_select", "NEW_SELECTION", "[Wall_Num] = " + row.getValue(field.name))
... View more
09-17-2011
04:42 PM
|
0
|
2
|
491
|
POST
|
Thank you Marc, I will digest the codes a little bit first myself. This is some amazing stuff! That.... is a thing of beauty!!! Thank you so much for sharing that, Luke! I just want to say that in the interest of giving the poster a smaller bit of code to dissect, one could make a smaller version using a filter and the exact example you were inspired by on the OS example page. import os
class DirectoryWalker:
'''Callously stolen (with attribution!) from os-path-walk-example-3.py
Copyright © 1995-2010 by Fredrik Lundh
http://effbot.org/librarybook/os-path.htm'''
def __init__(self, directory):
self.stack = [directory]
self.files = []
self.index = 0
def __getitem__(self, index):
while 1:
try:
file = self.files[self.index]
self.index = self.index + 1
except IndexError:
# pop next directory from stack
self.directory = self.stack.pop()
self.files = os.listdir(self.directory)
self.index = 0
else:
# got a filename
fullname = os.path.join(self.directory, file)
if os.path.isdir(fullname) and not os.path.islink(fullname):
self.stack.append(fullname)
return fullname
import shutil
search_dir = r'C:\Project'
out_dir = r'C:\Workspace'
# This filter takes all the results from DirectoryWalker and only iterates
# through those that match the condition 'file.endswith('.jpg')
for jpg in filter(lambda x: x.endswith('.jpg'), DirectoryWalker(search_dir)):
print('Copying: ' + jpg)
shutil.copy(jpg,out_dir) Diana: If you need any help understanding either of these examples, feel free to ask. Cheers, Marc
... View more
09-16-2011
06:04 AM
|
0
|
0
|
741
|
POST
|
I really appreciate your help! Thank you thank you thank you! You could use a recursive 'glob':
class rglob:
'''A recursive/regex enhanced glob
adapted from os-path-walk-example-3.py - http://effbot.org/librarybook/os-path.htm
'''
def __init__(self, directory, pattern="*", regex=False, regex_flags=0, recurse=True):
''' @type directory: C{str}
@param directory: Path to search
@type pattern: C{type}
@param pattern: Regular expression/wildcard pattern to match files against
@type regex: C{boolean}
@param regex: Use regular expression matching (if False, use fnmatch)
See U{http://docs.python.org/library/re.html}
@type regex_flags: C{int}
@param regex_flags: Flags to pass to the regular expression compiler.
See U{http://docs.python.org/library/re.html}
@type recurse: C{boolean}
@param recurse: Recurse into the directory?
'''
self.stack = [directory]
self.pattern = pattern
self.regex = regex
self.recurse = recurse
self.regex_flags = regex_flags
self.files = []
self.index = 0
def __getitem__(self, index):
import os
while 1:
try:
file = self.files[self.index]
self.index = self.index + 1
except IndexError:
# pop next directory from stack
self.directory = self.stack.pop()
try:
self.files = os.listdir(self.directory)
print self.files
self.index = 0
except:pass
else:
# got a filename
fullname = os.path.join(self.directory, file)
if os.path.isdir(fullname) and not os.path.islink(fullname) and self.recurse:
self.stack.append(fullname)
if self.regex:
import re
if re.search(self.pattern,file,self.regex_flags):
return fullname
else:
import fnmatch
if fnmatch.fnmatch(file, self.pattern):
return fullname
import shutil
search_dir=r'C:\Project'
out_dir=r'C:\Workspace'
for jpg in rglob(search_dir,'*.jpg'):
print 'Copying: ' + jpg
shutil.copy(jpg,out_dir)
... View more
09-16-2011
05:20 AM
|
0
|
0
|
741
|
POST
|
Hello, I am a new Python learner and have a task that I have to accomplish. I have a bunch of JPGs that are in the subfolder's subfolder (see below): C:\Project\Date\FolderA1\FolderA2\XXX.jpg C:\Project\Date\FolderA1\FolderA2\YYY.jpg C:\Project\Date\FolderB1\FolderB2\ZZZ.jpg C:\Project\Date\FolderB1\FolderB2\AAA.jpg What I really want to do is to point my code to C:\Project, then it can go through the subfolders and retrieve all JPGs then put it one single folder somewhere. I have been researching online, and cannot understand how this is done. If someone can help, I will appreciate it a lot!
... View more
09-15-2011
06:21 PM
|
0
|
7
|
893
|
Title | Kudos | Posted |
---|---|---|
1 | 09-28-2022 04:09 PM |
Online Status |
Offline
|
Date Last Visited |
12-13-2022
04:42 PM
|