Select to view content in your preferred language

FeatureLayer : Without ObjectId Field?

8527
29
04-02-2012 05:22 AM
__Rich_
Deactivated User
Hi,

I've got a layer within an AGS service that returns a load of point features based on dynamically changing data held in a non-spatial database via an ODBC connection, I'd like to connect a FeatureLayer to the service but it only renders a single feature in the map.

I can see from some investigations that the ESRI JavaScript relies (very heavily) on there being one field in the data that can be used as the 'ObjectIdField' to uniquely identify rows, there isn't an appropriate field in my data and I don't really want to arbitrarily generate something for these data.

Anyone found a way around this restriction?

Thanks.
0 Kudos
29 Replies
ChadWilcomb
Deactivated User
Try using a Query Layer to load the data into your MXD. Go to File -> Add Data -> Add Query Layer, connect to your database and write a query (or double-click on a table to Select *). Click "Show Advanced Options", then select one or more fields to create a unique identifier.
0 Kudos
__Rich_
Deactivated User
Try using a Query Layer to load the data into your MXD. Go to File -> Add Data -> Add Query Layer, connect to your database and write a query (or double-click on a table to Select *). Click "Show Advanced Options", then select one or more fields to create a unique identifier.


Thanks for the response, Chad - looks like it might work, I don't suppose you know where it stores the connection info?  I'm going to need to move the mxd to an AGS machine on a different network that hasn't got ArcDesktop installed so being able to re-map connections is a must, in the past I've achieved this using ODBC DSNs etc.

edit: found the .qcf file....it doesn't look portable!
0 Kudos
PaulBushore
Deactivated User
ArcCatalog connection information is usually kept in the hidden appdata folder for that user.  With 10, you can now copy and paste the database connection item in the ArcCatalog data tree and paste it where you want it.
0 Kudos
__Rich_
Deactivated User
ArcCatalog connection information is usually kept in the hidden appdata folder for that user.  With 10, you can now copy and paste the database connection item in the ArcCatalog data tree and paste it where you want it.


Thanks, Paul.

Yep, I've made use of that with .odc files in the past but it would appear that a connection created via "Add Query Layer" is a different kettle of fish, seems to have placed the connection information in a .qcf file which is presumably referenced by the mxd and cannot be moved.  Even if I could move it I'd have to go around naming all database host machines with the same name etc. or purchase a bucketload of ArcDesktop licenses for each AGS machine on each network!
0 Kudos
__Rich_
Deactivated User
Progress...maybe.

Created as per the 'wizard' then remapped data sources to .odc connection which in turn uses an ODBC DSN, deleted .qcf file and the data still display...so dependency on .qcf removed....I think.

So:

1.  ODBC DSN can be created anywhere, to point wherever I want
2.  .odc file can be created and copied to known location and references ODBC connection by its DSN
3.  mxd can be copied to known location and references .odc at known location thus can be connected to whatever server I want

Assuming, that's all valid, it can work...just a bit (very, very) convoluted.

Next problem is that the resultant layer won't accept simple definition queries e.g. Year(mydatetimefield) = 2012  "Failed to parse the where clause"!

I suppose I'll have to write all the queries in step 1 i.e. when adding the query layer!

Blimey.
0 Kudos
derekswingley1
Deactivated User
What's the reasoning behind not wanting to add an object id field client side?
0 Kudos
__Rich_
Deactivated User
Actually, scratch all that.

The step "Add Query Layer" that asks you to select the unique identifier fields is a problem, actually it's the original problem.

There are no fields in this dataset that consitute a unique identifier, it's the nature of the data.  If I choose a field or a composite of fields then effectively I'll be filtering out data because ArcDesktop will assume they're dusplicate records because they have matching 'key' values.

I just want the software to plot the points in the database, all of them.  AGS renders them all in the images it produces and it also provides them in the JSON is returns, it's just the client-side FeatureLayer code that lets the side down and unfortunately I need other parts of its functionality.

Thanks for the responses but it looks like this is a dead end.
0 Kudos
ChadWilcomb
Deactivated User
What's the reasoning behind not wanting to add an object id field client side?


Derek, do you have any samples on how to do this?
0 Kudos
derekswingley1
Deactivated User
It's simple to add a unique field to your data client side. You can do it with three lines of code, something like:

dojo.forEach(data, function(d, idx) {
  d.attributes.oid = idx;
});


And in your feature collection, make sure your field named oid (or whatever you choose to name it) has a type of esriFieldTypeOID.
0 Kudos