SVG to Lux Map File (PHP Code)

Lux maps won't make themselves.
Post Reply
User avatar
yi3artist
Luxer
Posts: 68
Joined: Tue Mar 01, 2005 7:36 pm
Location: Texas

SVG to Lux Map File (PHP Code)

Post by yi3artist » Fri Jul 24, 2009 12:38 pm

These are instructions to use Adobe Illustrator CS3 to export an SVG file, then use my PHP code to make a Lux map file.
Instructions assume you are using Adobe Illustrator CS3 to make the SVG, and that you can run PHP code on your system. My tutorial does not cover how to install PHP nor how to use Illustrator.

Download: Code & Tutorial
1. Download the zip file from http://sillysoft.net/lux/svg-to-luxb.zip
2. Unzip the contents:
  • a. This tutorial named "tutorial.rtf"
    b. The code named "svg_to_luxb.php"
    c. A test SVG named "map.xml"
4. Place the contents to a folder that Apache can access.

Adobe Illustrator CS3: Create an SVG
1. Draw the country shape vectors
  • a. Make sure the vectors have no curved lines.
    b. Make sure your points snap to a grid.
    c. Rectangles should be given an extra point to transform them into polygons.
2. Draw a rectangle the same size and position that the complete map should be.
3. Select the country shapes and map-size rectangle, then flip them upside down together.
4. Export the file as an SVG (default settings).

Text Editing & PHP: Save as Luxb
1. Save a copy of the SVG as "map.xml".
2. Place the "map.xml" in the same folder as the "svg_to_luxb.php" file.
3. Edit the "map.xml" file:
  • a. Make sure the "map.xml" file uses Unix-style newlines (LF).
    b. Polygons should not have coordinates with decimals.
4. Run the "svg_to_luxb.php" file in your browser.
  • a. If the page gives an error, follow the instructions on the page.
5. Edit the "map.xml" file.
  • a. Delete the rect fill="#______" width="___" height="___" line (the map-size rectangle vector).
6. Copy the resulting code to a text editor and save it as a .luxb file.

User avatar
paranoiarodeo
Semiholy Exile
Posts: 10421
Joined: Sun Jul 17, 2005 5:30 pm

Re: SVG to Lux Map File (PHP Code)

Post by paranoiarodeo » Sat Jul 25, 2009 3:37 pm

yi3artist wrote:b. Make sure your points snap to a grid.
FYI ... in my experience ... this doesn't guarantee integer coordinates ... decimals will sneak in occasionally ...

User avatar
yi3artist
Luxer
Posts: 68
Joined: Tue Mar 01, 2005 7:36 pm
Location: Texas

Re: SVG to Lux Map File (PHP Code)

Post by yi3artist » Sat Aug 08, 2009 10:52 pm

paranoiarodeo wrote:
yi3artist wrote:b. Make sure your points snap to a grid.
FYI ... in my experience ... this doesn't guarantee integer coordinates ... decimals will sneak in occasionally ...
Very true. I have to constantly confirm my points snap to that grid. Certain actions in Adobe Illustrator knock points off the grid ever so slightly without giving you any hint.

I normally drop or round sneaky decimals manually using find and replace.

User avatar
dustin
Lux Creator
Lux Creator
Posts: 10788
Joined: Thu May 15, 2003 2:01 am
Location: Cascadia
Contact:

Post by dustin » Thu Sep 13, 2012 2:09 pm

the download link doesn't work anymore. Does anyone have a copy of this tool? I would like to mirror it as a download form the Sillysoft server.

User avatar
yi3artist
Luxer
Posts: 68
Joined: Tue Mar 01, 2005 7:36 pm
Location: Texas

New Link

Post by yi3artist » Fri Sep 14, 2012 1:33 am

Here's an active link:
http://lux.yi3artist.com/archive/svg-to-luxb.zip

A mirror would be much appreciated.

I'd still like to make this an online tool someday... Y'know, one where you upload your svg file, and type in map data into a form similar to that in the app, then it spits out a snazzy download link for your .luxb file (and maybe even gives you a preview before-hand). Adult life changes priorities :?

User avatar
dustin
Lux Creator
Lux Creator
Posts: 10788
Joined: Thu May 15, 2003 2:01 am
Location: Cascadia
Contact:

Post by dustin » Wed Oct 10, 2012 6:45 pm

Thanks yi3artist. I've updated the top post with a link to the zip stored on the sillysoft server.

akeel1701
Lux Newbie
Posts: 4
Joined: Sun Aug 08, 2010 8:55 pm
Location: Glasgow

Re: SVG to Lux Map File (PHP Code)

Post by akeel1701 » Tue Sep 24, 2013 1:27 pm

Hi there

followed the instruction in the tutorial but the procedure does not appear to be working - do I need a specific version of a specific browser or does my system have to be up to a certain level?

I'm on a G5 iMac running system 10.4, and my browser is Firefox 3.6.28.

I've made my map in Illustrator, exported it as an SVG file, etc...

When i opened the php file in firefox it kept trying to save it, opening it in Safari showed me the code but little else.

I went to a site that could run PHP and it gave me this error:
<br />
Parse error: syntax error, unexpected '<' in [...][...] on line 1<br />
so I seem to have hit a brick wall at the moment, so if you can give me any thoughts on how to proceed further I'd greatly appreciate it.

Cheers
Akeel

Post Reply