Convert GML to SVG with XSLT, compress it, and publish a map of the vector.

Source: Internet
Author: User
Tags xslt
I have been very busy and busy. I have no time to write something .........

A demo written before 51. The Provinces. gml (only space data) of 3.8M is released into the compressed SVG and then 327 kb.
This is the load4.htm Code <! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN">
<Html>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
<Title> untitled document </title>
<Script>
Var svgEmb = null;
Var svgDoc = null;

Function init ()
{
SvgEmb = document. embeds ["SVG1"];
// Alert (svgEmb );
SvgDoc = svgEmb. getSVGDocument ();
SvgEmb. window. getURL ("line. aspx", loadSVG, "text/xml ");
}

Function loadSVG (templeContent)
{
If (templeContent. success)
{
Var domResponse = svgEmb. window. parseXML (templeContent. content );
Var frag = svgEmb. window. parseXML (svgEmb. window. printNode (domResponse. getElementsByTagName ("svg"). item (0), svgDoc );
// Frag. firstChild. setAttribute ("transform", "scale (1,-1 )");
SvgDoc. replaceChild (frag. firstChild, svgDoc. rootElement );
// SvgDoc. rootElement. appendChild (frag. firstChild );
SvgDoc. getElementById ("omVectorLayer"). setAttribute ("transform", "scale (1,-1 )");

Var svgRect = svgDoc. rootElement. getBBox ();
// Var svgRect = svgDoc. getElementById ("omVectorLayer"). getBBox ();
Var strViewBox = svgRect. x + "" + svgRect. y + "+ svgRect. width +" + svgRect. height;
// Alert (svgRect. x );
SvgDoc. rootElement. setAttribute ("viewBox", strViewBox );

}
}

Function getSvg ()
{
// Var oPop = window. open ();
// OPop.doc ument. body. innerText = svgEmb. window. printNode (svgDoc );
Alert (svgEmb. window. printNode (svgDoc ));
// SvgDoc. rootElement. setAttribute ("transform", "scale (1,-1 )");
}

Function getViewBox ()
{
Alert (svgDoc. rootElement. getAttribute ("viewBox "));
}
</Script>
</Head>

<Body onLoad = "init ()" bgcolor = "#666600" background = "background.jpg">
<Embed id = "SVG1" width = "500" height = "500" src = "test. svg"> </embed>
<Input value = "getsvg" type = "button" onClick = "getSvg ()">
<Input value = "getviewbox" type = "button" onClick = "getViewBox ()">
</Body>
</Html>

This is the line. aspx C # code, which requires ZIPLIB
This. Response. ContentType = "image/svg + xml ";
Transform transform xslt = new transform ();
Xslt. Load (Server. MapPath ("Region. xsl "));
XPathDocument xpathdocument = new XPathDocument (Server. MapPath ("chinese. gml "));

GZipOutputStream CompressedOutput = new GZipOutputStream (Response. OutputStream, 100 );
XmlTextWriter writer = new XmlTextWriter (CompressedOutput, Encoding. UTF8 );
Writer. Formatting = Formatting. Indented;
Xslt. Transform (xpathdocument, null, writer, null );
CompressedOutput. Finish ();

The following figure shows the current viewbox of the number. (A few provinces are missing because XSLT has not been written)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.