Проблема Mapnik и EPGS:3395

Mapserver, GeoServer, MapGuide, Google и другое ПО для веб-картографии
Ответить
agent-0007
Новоприбывший
Сообщения: 6
Зарегистрирован: 06 май 2009, 16:48
Репутация: 0

Проблема Mapnik и EPGS:3395

Сообщение agent-0007 » 06 май 2009, 16:58

Здравствуйте, пишу вам впервые. Рассчитываю на вашу помощь.

На системе установлен mapnik, WMS, proj и все для работы.
Показывает все OpenLayers

Возникла проблема в том, что при отрисовке в проекции EPGS:4326 все отрисовывается нормально, но поскольку проекция не та карта получается кривовата. Решил все перерисовать в проекции EPGS:3395 Меркатора
Но при отрисовке mapnik возвращает пустые тайлы.Никак не могу понять в чем дело( Дайте пожалуйста консультацию.

Рисовать карту в проекции EPGS:4326 не представляется возможным - потому что она получается кривая. прилагаю то что получилось в скриншоте. Может быть я что-то не так делаю?
Вложения
2.png
2.png (558.72 КБ) 9187 просмотров

Boris
Гуру
Сообщения: 4205
Зарегистрирован: 10 апр 2006, 22:34
Репутация: 433
Откуда: Париж

Re: Проблема Mapnik и EPGS:3395

Сообщение Boris » 09 май 2009, 04:28

Странно, что никто не ответил. :shock:
Если вы не напутали в номерах, то вторую проекцию вы выбрали презабавнейшую:
Область использования: World between 80°S and 84°N.
Масштаб: Very small scale mapping.
Примечание: Euro-centric view of world excluding polar areas.
Наверное вы хотели какую-то другую испоьзовать. На пример, судя по картинке, московский Кремль, должен хорошо смотреться на карте в проекции WGS 84 / UTM zone 37N - EPGS:32637

Аватара пользователя
Максим Дубинин
MindingMyOwnBusiness
Сообщения: 9128
Зарегистрирован: 06 окт 2003, 20:20
Репутация: 747
Ваше звание: NextGIS
Откуда: Москва
Контактная информация:

Re: Проблема Mapnik и EPGS:3395

Сообщение Максим Дубинин » 09 май 2009, 05:47

да нет, тут дело не в выбранной СК

если мапник оставить в покое, OpenLayers WMS в нужной вам СК правильно отрисовывает? В map-файле WMS поддержка этой СК заявлена?
пристегивайтесь, турбулентность прямо по курсу

agent-0007
Новоприбывший
Сообщения: 6
Зарегистрирован: 06 май 2009, 16:48
Репутация: 0

Re: Проблема Mapnik и EPGS:3395

Сообщение agent-0007 » 12 май 2009, 11:57

Про мап фаил можно по подробнее?
Я использую питоновские скрипты для отрисовки мапником.
Все данные берутся из Postgis. Туда я их загружал с помошью утилиты shp2pgsql который конвертирует шейпы.
При конвертации указал проекцию 3395, но при запросе у WMS сервера отрисовки в с проекцией отличной от 4326 я получаю пустой тайл.

В настройках ogcserver.conf я прописал проекцию 3395
Вот конфиг:

Код: Выделить всё

# $Id$
#debug=1
# server: This section contains software related configuration parameters.
[server]
# module:  The module containing the MapFactory class.  See the readme for
#          details.
module=maxFactory
#worldMapFactory
# service: This section contains service level metadata.
[service]
# title: The title of the server.
title=Mapnik OGC Server
# abstract: An abstract describing the server.
abstract=This abstract describes the server and its contents.
# maxwidth, maxheight: The maximum size that a map will be supplied at.
#                      Exceeding it will raise an error in the client.
maxheight=800
maxwidth=600
# allowedepsgcodes:  The comma seperated list of epsg codes we want the server
#                    to support and advertise as supported in GetCapabilities.
allowedepsgcodes=3395
# onlineresource:  A service level URL most likely pointing to the web site
#                  supporting the service for example.  This is NOT the online
#                  resource pointing to the CGI.
onlineresource=http://192.168.0.180/
# fees: An explanation of the fee structure for the usage of your service,
#       if any. Use the reserved keyword "none" if not applicable.
fees=
# keywords: A comma seperated list of key words.
keywordlist=
# accessconstraints: Plain language description of any constraints that might
#                    apply to the usage of your service, such as hours of
#                    operation.  
accessconstraints=
# maxage:            The content of the HTTP Cache-Control header - 
#                    the maximum age of the content in a cache, measured
#                    in seconds. One week is 604800 seconds, the default is
#                    1 day.
maxage=86400
# contact: Contact information.  Provides information to service users on who
#          to contact for help on or details about the service.
[contact]
contactperson=
contactorganization=
contactposition=

addresstype=
address=
city=
stateorprovince=
postcode=
country=

contactvoicetelephone=
contactelectronicmailaddress=


Вот пример кода 1 слоя:
# Database settings
		db_params = dict(
		dbname = 'mapnik',
		user = 'pga',
		table = 'buildings',
		password = '123456',
		host = 'localhost',
		)       
		
		
		
		#build_region type=1
		#srs
		build_type1_region_lyr = Layer('build_type1_region','+init=epgs:3395')
		build_type1_region_lyr.srs = srs
		db_params['table'] = '(select the_geom from %s WHERE type=1) as the_geom' % db_params['table']
		build_type1_region_lyr.datasource = PostGIS(**db_params)
		build_type1_region_style = Style()               
		build_type1_region_rule = Rule()

		l = LineSymbolizer(Color(205,170,102),0.40)
		l.stroke.opacity = 1
		l.stroke.linejoin = round
		l.stroke.linecap = round		
		
		build_type1_region_rule.symbols.append(l)
		build_type1_region_rule.symbols.append(PolygonSymbolizer(Color(246,204,204)))
		build_type1_region_style.rules.append(build_type1_region_rule)
		self.register_style('build_type1_region_style', build_type1_region_style)
		self.register_layer(build_type1_region_lyr, 'build_type1_region_style')

Код самого WMS сервера:
#!/usr/bin/env python

# Your mapnik dir containing the map factory
# must be in the python path!

import sys
sys.path.append('/opt/mapnik')

from mapnik.ogcserver.cgiserver import Handler
import jon.fcgi as fcgi

class WMSHandler(Handler):
    configpath = '/opt/mapnik/ogcserver.conf'

fcgi.Server({fcgi.FCGI_RESPONDER: WMSHandler}).run()
Я никак не могу понять в чем дело, расчитываю на вашу помощь...
Пробовал писать разработчикам mapnik, но ответа от них так и не получил(((

agent-0007
Новоприбывший
Сообщения: 6
Зарегистрирован: 06 май 2009, 16:48
Репутация: 0

Re: Проблема Mapnik и EPGS:3395

Сообщение agent-0007 » 12 май 2009, 12:07

Boris писал(а):Странно, что никто не ответил. :shock:

Наверное вы хотели какую-то другую испоьзовать. На пример, судя по картинке, московский Кремль, должен хорошо смотреться на карте в проекции WGS 84 / UTM zone 37N - EPGS:32637

хмм... а если я захочу в дальнейшем отрисовать всю Россию, а UTM zone 37N захватывает только Москву
spatialreference.org/ref/epsg/32637/

agent-0007
Новоприбывший
Сообщения: 6
Зарегистрирован: 06 май 2009, 16:48
Репутация: 0

Re: Проблема Mapnik и EPGS:3395

Сообщение agent-0007 » 12 май 2009, 17:46

нашел у мапника в SVN фаилик, вот пока только не понимаю, как этим пользоваться....

Код: Выделить всё

#
#
# Coordinate Transformations with Proj.4 using Mapnik python's bindings
#
#


# With Mapnik you can transform data back and forth between a projected system
# and unprojected, geographic coordinates (ie Longitude, and Latitude).
# Mapnik does not currently support transformations between two projected 
# systems in the python bindings, see: http://trac.mapnik.org/ticket/117


# Use `forward` to go from geographic coordinates to projected coordinates by
# initiating the projected coordinate system you'd like to convert into.


# Thus from WGS84 to World Mercator:

from mapnik import Coord, Projection
p = Projection('+init=epsg:3395')
long_lat = Coord(-122.0, 48.0)
mercator = p.forward(long_lat)
print mercator


# And to go from World Mercator to WGS84:

from mapnik import Coord, Projection
p = Projection('+init=epsg:3395')
mercator = Coord(-13580977.8768,6075085.09006)
long_lat = p.inverse(mercator)
print long_lat


# Note: it is easy to make the mistake of creating a Mapnik Projection Object in 
# the WGS84/geographic projection when needing to convert to and from this geographic
# projection and a projected system. Like in the above examples you need to create
# the projection object in a projected system.

# For example, this is wrong (but should be harmless since forwarding
# and inverting a geographic projection should do nothing):

from mapnik import Coord, Projection
p = Projection('+init=epsg:4326')
long_lat = Coord(-122.0, 48.0)
inv = p.inverse(long_lat)
forw = p.forward(long_lat)
if not inv == forw:
  print 'Something is wrong with your Proj.4/Mapnik Installation'
else:
  print 'No change'

agent-0007
Новоприбывший
Сообщения: 6
Зарегистрирован: 06 май 2009, 16:48
Репутация: 0

Re: Проблема Mapnik и EPGS:3395

Сообщение agent-0007 » 19 май 2009, 10:05

нашел решение проблемы. Проблема была в OpenLayers и коородинатах.

Ответить

Вернуться в «Веб-картография»

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и 1 гость