Jump to content
TNG Community

Automatically setting placelevel if using "Address, Location, Town, County, State, Country" format


GOGGS

Recommended Posts

Even though I frequently bulk update my placelevel field for places with queries, I wanted to make this more automatic.

I input my places with the format "Address, Location, Town, County, State, Country" so that drilling down in the placesearch pages works slick. So if you follow this "style", and place entry with no comma characters is a Country, e.g. USA, which is placelevel 6 is you're following the standard assignment. SC, USA or South Carolina, USA has 1 comma, and is a State, and so on. So if you count the commas in a place entry and subtract from 6, you get the placelevel (unless there are exceptions where addresses/places may have other commas. There are a lot of admin_ php files that update the tng_places table, and I've added this algorithm to them, along with a formula for zoom. It's a lot for creating a mod, IMHO, but I also changed the geocode function to add placelevel (i.e. when that is used to bulk update places).

Here's the code I used for those that are interested, and if enough find it useful, then maybe we created a published mod?

// These lines are added prior to a INSERT INTO $places_table query...
	$placelevel = 6 - substr_count($place, ","); // State = placelevel 5
	$zoom = 22 - (3 * $placelev); // Country = zoom 4, State = zoom 7, etc.


	

Cheers

 

GOGGS

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...