Broken / Missing line edges

View: New views
2 Messages — Rating Filter:   Alert me  

Broken / Missing line edges

by Adnan Khan-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Guys,

I'm testing Mapnik 0.6.0 & 0.5.1 (on Windows platform) and came across a very strange scenario. I have noticed Mapnik sometimes cuts / slashes styled road edges (styled lines in my case) around the tile corners i.e. roads finish abruptly. I know there have been some problems with missing labels,symbols,etc but I cannot find anything on missing / cut styled edges. Is there a fix / workaround for this problem?

I have attached a png image highlighting the problem (with vector data shown on top of created rasters)  and the python script used to generate tiles. The original shp file used to create samples has been uploaded since 700kb exceeds max allowed limit here, download link given below.

http://pzh6gq.blu.livefilestore.com/y1pjcNP-HcqKN87z7hxUSwkHhozm_aC61po5hlFe9k8gChYhFVhj71M4Xwnq2wdpfoHIoNmJJw8tSVdBmYSKSVRhzOj__MJXaf5/sample.zip?download

I would greatly appreciate any help in this matter.

Thanks
--
Adnan Khan

'''
Created on 20 May 2009

Creates samples images from Mapnik.

Images are created in the same dir as base shp file for roads.
'''
from mapnik import *
import os

shp_file_loc = 'C:\\sample\\sample'
output_dir = os.path.dirname(shp_file_loc)
label_field = 'STREET_NAM'

tile_size = 800
m = Map(tile_size,tile_size,"+proj=tmerc +lat_0=49 +lon_0=-2 +k=0.9996012717 +x_0=400000 +y_0=-100000 +ellps=airy +datum=OSGB36 +units=m +no_defs")
m.background = Color(240,240,240)

start_x,start_y,end_x,end_y = 475000,260000,477000,262000


def createSHPLayer(file_path,lyr_name,style_names):

    lyr = Layer(lyr_name)
    lyr.datasource = Shapefile(file=file_path,encoding='latin1')
   
    for style_name in style_names:
        lyr.styles.append(style_name)
   
    return lyr

def createLineStyle(style_name,width=7,rgb='orange'):
   
    s = Style()
    stk = Stroke()
    stk.width = width
    stk.color = Color(rgb)
    stk.line_cap = line_cap.ROUND_CAP
    r = Rule()
    r.symbols.append(LineSymbolizer(stk))
    s.rules.append(r)
    m.append_style(style_name,s)
   
    return s

       
def createLineText(style_name,field_name='stnm_base',font_size=10,rgb='black'):
   
    s2 = Style()
   
    r2 = Rule()
   
    t2 = TextSymbolizer(field_name,'DejaVu Sans Book',font_size,Color(rgb))
    t2.label_placement = label_placement.LINE_PLACEMENT
    t2.halo_radius = 1
    t2.halo_fill = Color('yellow')
    t2.allow_overlap = True
    t2.avoid_edges = True
    t2.max_char_angle_delta = 20
    t2.minimum_distance = 50
    t2.label_spacing = 100
    t2.avoid_edges = True
   
    r2.symbols.append(t2)
    s2.rules.append(r2)
   
    m.append_style(style_name,s2)
   
    return s2

# Create styles
createLineStyle('road fill',4.5)
createLineStyle('road border', 5.5, 'gray')
createLineText('road labels',label_field)

# Create source and append styles to it
road_layer = createSHPLayer(shp_file_loc, 'roads', ['road border','road fill','road labels'])
m.layers.append(road_layer)

for i in range(2):
    m.zoom_to_box(Envelope(start_x,start_y,end_x,end_y))
    render_to_file(m,'%s\\%s.png' % (output_dir,i),'png256')
    scale = m.scale()
    extent= m.envelope()
    upper_left_x_center = extent.minx+(scale/2)
    upper_left_y_center = extent.maxy+(scale/2)
    x_rotation = 0.0
    y_rotation = 0.0
    wld_string = '%f\n%s\n%s\n-%f\n%f\n%f\n' % (scale,y_rotation,x_rotation,scale,upper_left_x_center,upper_left_y_center)
    wld_file = open('%s\\%s.wld' % (output_dir,i), 'w')
    wld_file.write(wld_string)
   
    start_y = end_y
    end_y += tile_size







_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users

problem.PNG (27K) Download Attachment

Re: Broken / Missing line edges

by Dane Springmeyer :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Adnan,

That is strange. I've not seen that before with Mapnik.

I tried to download your sample data but the link results in an empty file. Could you attach the sample shapefile, and the simpliest possible testing script that you can re-create the problem with to a Trac ticket?

Dane


On May 20, 2009, at 6:39 PM, Adnan Khan wrote:

Hi Guys,

I'm testing Mapnik 0.6.0 & 0.5.1 (on Windows platform) and came across a very strange scenario. I have noticed Mapnik sometimes cuts / slashes styled road edges (styled lines in my case) around the tile corners i.e. roads finish abruptly. I know there have been some problems with missing labels,symbols,etc but I cannot find anything on missing / cut styled edges. Is there a fix / workaround for this problem?

I have attached a png image highlighting the problem (with vector data shown on top of created rasters)  and the python script used to generate tiles. The original shp file used to create samples has been uploaded since 700kb exceeds max allowed limit here, download link given below.

http://pzh6gq.blu.livefilestore.com/y1pjcNP-HcqKN87z7hxUSwkHhozm_aC61po5hlFe9k8gChYhFVhj71M4Xwnq2wdpfoHIoNmJJw8tSVdBmYSKSVRhzOj__MJXaf5/sample.zip?download

I would greatly appreciate any help in this matter.

Thanks
--
Adnan Khan
<mapnik-test.py><problem.PNG>_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users


_______________________________________________
Mapnik-users mailing list
Mapnik-users@...
https://lists.berlios.de/mailman/listinfo/mapnik-users