Mapnik Blue Tiles with TileCache - mapping

I am still trying to get my server running OpenStreetMap. I have TileCache and Mapnik installed. I have an extract of the U.S. state of Oklahoma imported into my database. I have used OSM Mapnik tools to create an XML stylesheet and I have confirmed that 'generate_image.py' makes a nice map image. I have (at least I believe I have) granted PostGIS access properly. My user has full permissions over all of the tables in the database. When I look in the Apache logs, all I see are notes about cache misses (I used to see database connection issues, but I don't any more). In the Postgres logs, I don't see anything (again, I used to see access denied issues, but I don't anymore). Despite all of this, when I ask TileCache to render a tile from the OSM Mapnik layer, all I get is this image:
This image shows up no matter where I am on the map or what zoom level I am at. I have TileCache running under CGI and it has a configuration like this:
[osm]
type=Mapnik
mapfile=/var/maps/bin/mapnik/osm.xml
spherical_mercator=true
I am using OpenLayers and my Javascript looks like this:
var map = new OpenLayers.Map("mapdiv");
var vec = new OpenLayers.Layer.TMS("TC", "http://maps.company.com/cgi-bin/tilecache/tilecache.cgi/", {serviceVersion: "1.0.0", layername: "osm", type: "png"});
map.addLayer(vec);
I have been working on this server for two and a half weeks. I have read every blog, forum, or other post I can find. This is my third question today. I am getting desperate. I would really appreciate any help anybody has.

Can you confirm that you have valid data in postgis? Opening up the data in Quantum GIS is a good way to check.

Related

Create an offline version of web application

Question :
Where to start to write an application which can work without internet connection? Exactly like this
Explanation :
Say we have an web application which is already deployed. Since internet is not great in INDIA, I would like to create an offline version of same web application which users/people can access without internet as well. I want them to experience similar stuff of web interface without much of the changes.
One idea that came to my mind is to create a tar ball of contents of application and ship to the people/users. Users will have to use that tar ball to install/configure on their machine so that they can use it. Contents of tar ball is also debatable that what should I enclose in that tar ball. Apache, Technology stack etc etc.
I will be happy to write more in case I have not written precisely. My question is not related to any technology stack but this might be of interest to everyone. Since I am not sure which is the right tag to append here, can anybody from stackoverflow team help to tag right tag. :)
My application is actually in RoR. So, Tagging ruby on rails community. May be they can help here?
As long as your web application contains only flat files (HTML, CSS, JS, text data, etc.) and does not depend on any components that need to be installed, then you can simply distribute those files in an archive (.zip will be more cross-platform-friendly) and the user could open the application by opening the front page in a browser. To make it better for the user, a small application which invokes the user's browser with the local URI should also be included.

How to check which external connections are being used by my website

I'm not 100% sure if this is a programming question, but I do believe I'm targeting the correct audience for this issue.
I've built a web-based frontend for an application. Now the frontend will be deployed to the customer's machine (localhost-based website). However, this frontend uses Google Maps V3 and some other external components. It will need internet access, but the customer network is highly secured. Here my issues begin.
To make sure everything works as planned, we need to allow the connections that are being made when starting up the webpage, so I need a list of URLs that my frontend is using when starting up. I mainly need the google maps URLs, they are so varied (googleis.com, gstatic.com, ...)
How can I get a list of these URLs? Is there any Google documentation (didn't find any)?
I've thought about using Firebug and listing all entries in the Network tab. However, that scales to about 2000 items (including all images, scripts, CSS stylesheets etc that are being loaded from the local website).
Or is there a tool/workaround to easily find out which connections should be explicitly allowed for the website to work like it should?
Your approach of using the Firebug - Network tab is good. The Chrome Developer Tools - Network view is also very good. I haven't seen a list of everything that gets loaded by the map, but that is because it varies based on how you set up your map. I know that Google works hard to only load what is needed by your map, based on your options.
So if you only use selected map controls, Google will try to limit the image downloads to just what is needed to display the controls your map needs. Of course, if you include additional items, such as using a parameter on the URL that loads the drawing tools (libraries=drawing), you will have additional network loading. Google defined these "extra" items as libraries to avoid loading everything; just those that need them will have to load them.
Other than setting your map up and watching what is loaded, I can't think of another option.

TileCache with Mapnik for OpenStreetMap

I have an OpenStreetMap server that uses TileCache to serve tiles. The tiles are generated with Mapnik. I have configured the Mapnik XML stylesheet and I can generate an image with the OSM Mapnik tool 'generate_image.py'. That image is correct and looks good.
My TileCache server will serve tiles from my OSM layer; however, all I get are tiles with the background/water blue. I get no land forms, I get no street data. Can anybody help with this?
TileCache Config:
[osm]
type=Mapnik
mapfile=/var/maps/bin/mapnik/osm.xml
spherical_mercator=true
I am using OpenLayers to show the map. I am using a TMS layer to call the TileCache server. Like I said, I get tiles returned, they are just nothing but blue.
This is likely happening because tilecache runs as the apache user (various names) which has different privileges than your normal unix user for which you used to test tile generation with TileLite and generate_image.py.
See http://dbsgeo.com/foss4g2010/html/troubleshooting.html#trouble-postgres-connection for advice, but know this is simply a postgres issue and it is up to you to decide how to configure and your necessary security needs.

Issues with Filemaker IWP working with hyperlinks on images

I have a filemaker database that I need to be able to link records and all associated data (including container field data) to various points placed on a large PDF image, and then make that data appear via instant web publishing when someone clicks on the marker for that area on the PDF. For example the PDF may be an image of a car, and then I would have various close up images of issues with the car and descriptions of those images as records in the database. I would then want to drop points on the base PDF image and when you clicked on those points be able to see the close up images and other data related to those images.
I'm being told this is too much for IWP because:
I need to place the markers outside filemaker via PDF annotation
Filemaker IWP can't handle the number of markers that may be necessary (it could be up to 1,000 on an E sized image.
Does anyone have a work around or explanation why this is a problem?
If I understand correctly, you would like to setup a PDF with links that will open a browser and show data related to what was clicked. Assuming that is the case, the reason this wont work is because IWP does not provide a unique URL for a unique page. For example, here on StackOverflow you can directly link to any question based on its URL:
http://stackoverflow.com/questions/3207775/ -- this question
http://stackoverflow.com/questions/4973921/ -- some other question
IWP uses Javascript and session variables to manipulate the output to the screen, so there is no way to link to a specific section of your IWP site, since the URL is always something like:
http://yoursite.com/fmi/iwp/cgi?-db=YOUR_DB-loadframes -- Product A
http://yoursite.com/fmi/iwp/cgi?-db=YOUR_DB-loadframes -- Product B
http://yoursite.com/fmi/iwp/cgi?-db=YOUR_DB-loadframes -- Product C
Because of the limited nature of IWP, you will not be able to workaround this issue. You'll need to build your own web-interface using the Custom Web Publishing Engine, either using the built-in PHP extensions or some other technology where you invoke the XML publishing API.
I agree with Nate
IWP is the wrong solution to this problem. You'd be better off simply hosting those images on a webserver.
Now here comes the plug, you can use SuperContainer to really simplify the management of the images from FileMaker.

Get country location of an IP with native PHP

Read on before you say this is a duplicate, it's not. (as far as I could see)
I want to get the county code in php from the client.
Yes I know you can do this using external sites or with the likes of "geoip_record_by_name" but I don't want to be dependent on an external site, and I can't install "pear" for php as im using shard Dreamhost hosting.
I thought I could just do something like this:
$output = shell_exec('whois '.$ip.' -H | grep country | awk \'{print $2}\'');
echo "<pre>$output</pre>";
But dreamhost seems to have an old version of whois (4.7.5), so I get this error on allot of IPs:
Unknown AS number or IP network. Please upgrade this program.
So unless someone knows how to get a binary of a newer version of whois onto dreamhost im stuck.
Or is there another way I could get the country code from the client who is loading the page?
Whois is just a client for the whois service, so technically you are still relying on an outside site. For the queries that fail, you could try falling back to another site for the query, such as hostip.info, who happen to have a decent API and seem friendly:
http://api.hostip.info/country.php?ip=4.2.2.2
returns
US
Good luck,
--jed
EDIT: #Mint Here is the link to the API on hostip.info: http://www.hostip.info/use.html
MaxMind provide a free PHP GeoIP country lookup class (there is also a free country+city lookup one).
The bit you want is what is mentioned under "Pure PHP module". This doesn't require you to install anything, or be dependent on them, nor does it need any special PHP modules installed. Just save the GeoIP data file somewhere, then use their provided class to interact with it.
Can you just install a copy of whois into your home directory and pass the full path into shell_exec? That way you're not bound to their upgrade schedule.
An alternative, somewhat extreme solution to your problem would be to:
Download the CSV format version of MaxMind's country database
Strip out the information you don't need from the CSV with a script and ...
... generate a standard PHP file which contains a data structure containing the IP address as the key and the country code as the value.
Include the resulting file in your usual project files and you now have a completely internal IP => country code lookup table.
The disadvantage is that, regularly, you would need to regenerate the PHP file from the latest version of the database. Also, it's a pretty nasty way of doing it in general and performance might not be the best :)
Consider ipcountryphp (my site, my code, my honour) as it provides a local internet-lifetime freely updated database. It's fast and fully self-contained, pluggable into anything PHP 5.3, SQLite3 and beyond. Very fast seeks and no performance penalties.
Enough with shameless self-promotion, let's get serious:
Relying on querying remote services in real-time to get visitor country can become a major bottleneck for your site's functionality depending on the response speed of the queried server. As a rule of thumb you should never query external services for real-time site functionality (like page loading). Using APIs in the background is great but when you need to query the country of each visitor before the page is rendered, you open yourself up to a world of pain. And do keep in mind you're not the only one abusing free services :)
So queries to 3rd-party services stay in the background while only local functionality that relies on no 3rd-party go into the layers there users interact with. Just my slightly performance paranoid take on this :)
PS: Above mentioned script I wrote has IPv6 support too.
Here is a site with a script i just used. The only problem is that you would probably every now and then need to regenerate IPs by yourself... which might be pain and tahts why everyone is telling you to use external API. But for me that wasnt solution as i was pulling like 50 IPs at once, which means i would probably get banned. So solution was to use my own script or to do saves to DB, but i was again pulling images from external sites. Anyway here is the site i found script on:
http://coding-talk.com/f29/country-flag-script-8882/
Here's a few:
http://api.hostip.info/get_html.php?ip=174.31.162.48&position=true
http://geoiplookup.net/geoapi.php?output=json&ipaddress=174.31.162.48
http://ip-api.com/json/174.31.162.48?callback=yourfunction
http://ipinfo.io/174.31.162.48
All return slightly different results.
here is also one of them. just change the IP to the variable:
http://api.codehelper.io/ips/?callback=codehelper_ip_callback&ip=143.3.87.193

Resources