A company (ESRI) that produces software I use for storing, analyzing and viewing geographic data has released a JavaScript-based API, built on the Dojo JavaScript Toolkit, for creating web maps. I would like to use the API to extract information (the geographic extent centroid) about a geospatial dataset and store into CCK fields. The stored coordinates are then displayed on a map using the GMap and Views modules. I've reviewed the Computed Fields module but I'm uncertain if this module can help. Ideally, retreiving the extent centroid and saving to CCK fields would occur when new content was submitted (for the custom content type "Geospatial Data").
I'm confident that the mental block is with my inexperience but without knowing what steps to take, I'm feeling very helpless. I have succeefully used the API outside of Drupal so at least I know my mental block is only between the API and Drupal. I hope someone out there will come to my rescue. I'm not looking for step by step instructions, just an outline of what I need to learn to get things productive.
Cheers!
Comments
Did you allready have a look
Did you allready have a look on http://drupal.org/project/geocode and http://drupal.org/project/geo. You could write an additional handler for gecode supporting a textfield - or however you want to input the data. Geocode then could retrieve your data and store it in a geo cck field.
This field then can be used in views, gmaps, openlayers maps.
I have had a look
I have had a look at the modules you recommended but in order for me to implement one of them I would need to completely change how my existing data is stored and published on the web. I'm simply trying to collect some basic information about a dataset (which has been published on the web using REST web services) and collate all content type of type "Geospatial Data" in lists and a google map. Essentially what I'm trying to create here is a Geoportal where users can view geospatal data by type, project or by geographic location (this is where using the JavaScript API to extract the extent centroid comes in).
Do you have an example set of
Do you have an example set of what data you want to store, how, and what data will be retrieved from the JS API?
There will be 2 CCK textfields
There will be 2 CCK textfields and 2 CCK float fields for my custom content type. The textfields will store the map service and filtering query string. The 2 float fields will store the latitude and longitude of the geographic extent centroid of dataset. Using the 3rd part JavaScript API, all I need to provide to the API is the map service and the filtering query string. Here is a link to a functioning application that returns the extent centroid after submitting the map service and filtering query string: http://bcmw.coastal.edu/ags_js1.html.
Use "http://sampleserver1.arcgisonline.com/ArcGIS/rest/services/Demographics/ESRI_Census_USA/MapServer/5" for the Map Service URL field and "STATE_NAME = 'South Carolina'" for the Definition Query field. Drop the double quotes for each one before entering into the field. Click "Get Details" and voila, the extent centroid is displayed to the screen. The map display is NOT necessary for the application to work.
So when adding new content the user enters the map service and filtering query string. What I would like to do is use the API to retrieve the extent centroid coordinates and store this information in the latitude and longitude CCK fields on submit. As mentioned I have reviewed the Computed Fields module which allows for these sort of operations but from what I have see, PHP is used for the computation and I am not familiar enough with PHP and JavaScript to know if they can work together and also if they can do so within the Drupal framework.
Don't you want to store a
Don't you want to store a polygon instead of point(long/lat)? So a Geospatial Data Field would be right for you, as it stores in WKT format, so polygons, linestrings and points are available.
Hm, as you don't know PHP, it's obvious you don't want to write a drupal module for that, but you will have to, at least if you don't want to get dirty.
Am I right, or don't I get to the point?
No I'm already using
No I'm already using a commercial GIS to store/view/analyze my data, I only want to store the extent centroid in Drupal so I can use the GMap module to display the point on the map. This way, users can see where the datasets are located relative to each other. If they want to see the actual data, the have to go to the node page that corresponds with that point. The on the corresponding node page, I use a separate API (Flex-based - released by the same company, ESRI) to display the data onto an interactive web map. Here is an example http://bcmw.coastal.edu/drupaldev/geoportal/arcadian-beach-survey-november-2006.
I think you might be missing the point. I want to use the API to extract the extent centroid only. I'll then need to store the lat long into a CCK field. I would like for this to be an automated process which will occur when I submit the new node for the content type, Geospatial Data. Once I have the lat long for all nodes of type Geospatial Data, I can then use the GMap module to show the locations of where data is available. I have tested the last item by manually entering the lat long into two CCK fields for a handful of nodes, creating a view and using GMap to make the map. This works fine so I do not need to worry about this. All I am worrying about is automating the extraction of a datasets extent centroid.
I do know how to write PHP but I am not an expert and I'm still learning Drupal customization with PHP. I also am not familiar with how I can use JavaScript within the Drupal environment since I'm assuming I'll need to use PHP with the JavaScript API.
I appreciate your willingness to help me with this. I hope to be able to accomplish this as it would really help me to maintain a data portal.
Can you export the data as
Can you export the data as KML? If so, you then have an opportunity to import using the Feeds API http://drupal.org/project/parser_kml. The Mapstraction module allows to switch map services on the fly. And the Openlayers module can map points, lines and polygons. The Openlayers module uses two views to manage data. First, is the geographic dataset and the second renders the dataset onto a map. It's very easy to create exposed filters.
Marine job board with Drupal 7 at http://windwardjobs.com
Use ReST API and JSON?
Is there a reason you need to use the javascript API? The ReST API seems to allow you to query for your data. Although I do not see a centroid listed in any of the sets. I see extent max and mins. Those could be pulled out of the JSON returned by the ReST API using a method like this: http://drupal.org/node/277619