Tekforums

Chat => Entertainment & Technology => Topic started by: zpyder on February 11, 2010, 13:03:17 PM

Title: Help required with some coding and sql type stuff! :|
Post by: zpyder on February 11, 2010, 13:03:17 PM
Basically my boss likes an idea I proposed to avoid the issue of sending out 250+ large OS maps for people to mark locations on and return in the post, where we would use google maps/earth or similar to get people to place markers on the map, which would then be stored/emailed so that they could be imported into the GIS program we use for analysis.

Originally I was thinking of setting up a 50 odd google mymaps and inviting people to contribute to each one, but this is pretty complicated for joe bloggs and isnt very efficient. Then it was suggested about doing stuff with the API, which makes sense, but coding and development is the reason why I got out of computing in the first place so Ive been pulling my hair out all day so far!

Ive come across a useful set of tutorials/information regarding google maps api stuff, including this page:

http://econym.org.uk/gmap/store.htm

Im guessing I should be able to sort something out on a basic level where its running on a server and people can add their markers, BUT the problem is ideally we want to make it so that each person seeing the map doesnt see the other markers. So I need some form of user session thing.

Im guessing the way would be to sort out some mysql database for users, with an entry page that asks the person to enter their name and unique code sent in the email/letter, which would then be stored and assigned a unique identifier which would allow the person to edit the map, saving everything to the database. When the next person comes along to the site, they get a different identifier starting a different session?

Problem is Ive never done anything like this before so dont even know where to start, if indeed this is the best way to go about it all!?!
Title: Re:Help required with some coding and sql type stuff! :|
Post by: shofty on February 12, 2010, 09:43:46 AM
you could do with  a framework like django to take all the pain of users, auth and session data away from you.
Ive only been using it a few months, but i think it could do a job.

let me research it tonight if you dont get any other answers back.

Title: Re:Help required with some coding and sql type stuff! :|
Post by: zpyder on February 12, 2010, 11:58:06 AM
Thanks!

Ive had one suggestion of using Drupal, which I was playing around with yesterday. It does seem to have several google map modules, but the whole interface is pretty alien to me as Im used to Joomla. The help/guidance on how to do even basic things like install modules is pretty lacking, even though the installation is pretty easy! Ive yet to figure out how to get a module visible on the main page too!

http://www.zpyder.co.uk/mapping/

I might end up popping in to uni tomorrow as a lecturer has put up an example bit of code that should do what I want with a little bit of modification, but its running on a local server so I have no access via the internet!
Title: Re:Help required with some coding and sql type stuff! :|
Post by: zpyder on February 15, 2010, 11:10:41 AM
So theres this page on googles development stuff, and it might as well be in martian as it makes next to no sense at all:

http://code.google.com/apis/maps/documentation/mapsdata/developers_guide_protocol.html#CreatingFeatures

I know that technically it should do what I want (I think) but what all the functions are and how to use them in normal terms is beyond me :(
Title: Re:Help required with some coding and sql type stuff! :|
Post by: zpyder on February 15, 2010, 15:12:09 PM
Well Ive managed to get something to work the way I want, sort of.

http://www.zpyder.co.uk/tess/mapping/test.html

Itll allow people to make new points, which is at least the first step. Now all I need to do is figure out how to let them edit them, and make a user session control so that they can only see and edit the points they made.
Title: Re:Help required with some coding and sql type stuff! :|
Post by: shofty on February 15, 2010, 16:40:35 PM
i did a bit of research and django has a module for this very thing. geodjango.

should be quite easy to sort.

not sure when ive got time to look at it, how desperate are you?

Matt
Title: Re:Help required with some coding and sql type stuff! :|
Post by: zpyder on February 15, 2010, 17:41:58 PM
Problem is installing it on my server which uses cpanel, unless I want to sort out another server to play with?

Currently scratching my head over how to code the following to create page breaks in the description of each marker:

     // === Define the function thats going to read the stored data ===
      readData = function(doc) {
        // === split the document into lines ===
        lines = doc.split("\n");
        for (var i=0; i          if (lines[i].length > 1) {
            // === split each line into parts separated by "|" and use the contents ===
            parts = lines[i].split("|");
            var lat = parseFloat(parts[0]);
            var lng = parseFloat(parts[1]);
            var value = parts[2];
   var score = parts[3];
            var point = new GLatLng(lat,lng);
            // create the marker
            var marker = createMarker(point,[value+"
"+score]);
          }
        }
      }          
      // === read data entered by previous users ===
      GDownloadUrl("details.txt", readData);      


Its
           var marker = createMarker(point,[value+"
"+score]);


Which is causing the problem :/
Title: Re:Help required with some coding and sql type stuff! :|
Post by: shofty on February 16, 2010, 09:22:39 AM
silly suggestion but tried



Title: Re:Help required with some coding and sql type stuff! :|
Post by: shofty on February 16, 2010, 09:26:48 AM
found this code.


      iconsm.image = "http://www.mapbuilder.net/img/icons/marker_20_red.png";
      var InfoHTML = "

Altoona

Altoona. Favorite shopping place of my wife.
Some info about city available at www.altoonapa.gov
" + footerHtml + "
";
      var marker = createMarker(point, InfoHTML, iconsm);


dragging your html onto a var looks like a good idea.

Matt
Title: Re:Help required with some coding and sql type stuff! :|
Post by: zpyder on February 16, 2010, 15:45:45 PM
Yeah, I tried several things, I think from what Ive read, using the coding Ive borrowed doesnt allow for html in the info-window. Ill give that latter suggestion a try though later on.

Being a total numpty, what language is this all in, is it java etc? I have no point of reference on what can and cant be done other than the stuff for the api. I ask as there are things Id like to see if I can do such as create a checking window/pop-up which will check the values entered in the text file on the page to see if they add up to 100 (or 0) and inform the user if not.

My next 2 things to do on the list are:

1 - Make the first text field when setting a new marker a drop down box with 3 text/string options.
2 - create a submit button at the bottom of the page the user clicks when done. This wont actually submit the data (each marker is saved automatically), but instead will drop me an email so I know the user is finished. BUT, before it does this I want it to run a routine to check that the fields tally to 100 as mentioned above, and prevent the user with a pop-up to inform them if they dont.

The format is in:

50.71863437930215|-2.2721099853515625|Aesthetic|80|
50.69015056613803|-2.04345703125|Recreational|30|

with lat|long|Type|score

I want to parse that and make sure the total score for all lines with Aesthetic in them = 100, or that there arent any lines.

Its all a bit over my head, though im slowly chipping away at most stuff. I do find this easier than the many other pre-made alternatives Ive tried (www.zpyder.co.uk/maps) - some joomla modules that do what I want, sort of, but are flawed in one way or another!
Title: Re:Help required with some coding and sql type stuff! :|
Post by: shofty on February 17, 2010, 09:11:00 AM
youre coding in javascript from the looks of it.
Title: Re:Help required with some coding and sql type stuff! :|
Post by: zpyder on February 17, 2010, 12:46:36 PM
bah humbugness. They now want me to code it to write everything to a database. Its great when it all works, but its a total pita getting there :(
Title: Re:Help required with some coding and sql type stuff! :|
Post by: shofty on February 17, 2010, 13:18:08 PM
seriously, I think gedjango is the way forwards.
using django you get the whole authentication system and database side of things handled for you. so all youre doing is writing the logic.

foundt this which has a video you might like to watch.
http://invisibleroads.com/tutorials/geodjango-install.html

only thing is, it looks like a chew to install the libraries geo uses.

Matt

Title: Re:Help required with some coding and sql type stuff! :|
Post by: zpyder on February 17, 2010, 17:19:15 PM
Ive gotten the script to save into the database now :) Now I need to figure out how to get the data out! Once Ive gotten that it should be very easy to add some extra bits here and there for basic user/pass and to only show the markers for the currently logged in user. a simple form on entry for a username and password and a few other required details for the survey can go into a table in the database. Doesnt need to be anything fancy as the user/pass is just to ensure that the records are unique for each person. Can then filter to show only the markers for the current user, and jobs a goodun.

I think that perhaps something like geodjango might look awesome, but consider the fact that this is part of an EC funded research project into methods for evaluating ecosystem services. The boss and some other people at Uni are quite excited about this stuff as its essentially making a lightweight system that is easily transferable and distributable. In a scientific/research perspective its excellent as so far the code is short enough to be stuck in an academic paper, whilst something like geodjango is a lot more bulky requiring more specialist knowledge etc. It also takes me just as long to find out how to work around these pre-built systems and to customise them as needed as it does to do it myself!

One of the peeps at work is also excited as hes been trying to get them to let him get a school server for stuff like this, and now he has a live example & reason for why its needed. Certainly Id want to put this stuff on it ASAP as I have no idea how insecure all these bits of code are in terms of opening up access to the rest of the site?! Im quite happy to pursue this as I dont have too much else to do on the project right this second and judging by the reactions of some of the higher-ups if I can do an alright job of it, it might lead to more work...work I find dull and headache inducing, but work nonetheless. Its about time I actually learnt to code anyway.

As to my question about the code language being used I should have just read what was in the source:

Quote