Skip to content

Commit

Permalink
-fix for SVG Direction of Movement modifier
Browse files Browse the repository at this point in the history
-checked in svg webworker example
  • Loading branch information
Spinelli committed Aug 26, 2016
1 parent d99fa38 commit 68e905d
Show file tree
Hide file tree
Showing 7 changed files with 425 additions and 25 deletions.
28 changes: 25 additions & 3 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<!-- Rendering Utility imports -->
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/Color.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/AffiliationColors.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/ErrorLogger.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/MilStdAttributes.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/RendererUtilities.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/ImageInfo.js" />
Expand Down Expand Up @@ -83,10 +84,9 @@
<!-- Rendering Utility imports -->
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/Color.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/AffiliationColors.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/ErrorLogger.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/MilStdAttributes.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/RendererUtilities.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/ImageInfo.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/TextInfo.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/ModifiersUnits.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/ModifiersTG.js" />
<fileset file="web/js/src/armyc2/c2sd/renderer/utilities/RendererSettings.js" />
Expand Down Expand Up @@ -1019,6 +1019,22 @@
<fileset file="build/single-body-svg.js" />
</concat>
</target>

<!-- Build single point SVG-only, B-only, jQuery renderer-->
<target name="sv-b">
<concat destfile="dist/sv-b.js">
<fileset file="build/single-b-header.js" />
<fileset file="build/single-body-svg.js" />
</concat>
</target>

<!-- Build single point SVG-only, C-only, jQuery renderer-->
<target name="sv-c">
<concat destfile="dist/sv-c.js">
<fileset file="build/single-c-header.js" />
<fileset file="build/single-body-svg.js" />
</concat>
</target>

<!-- Build multi point-only, B-only, no jQuery renderer-->
<target name="m-b">
Expand Down Expand Up @@ -1092,17 +1108,22 @@
<antcall target="s-b" />
<antcall target="s-c" />
<antcall target="s-bc" />
<antcall target="sv-bc" />
<antcall target="m-b" />
<antcall target="m-c" />
<antcall target="m-bc" />
<antcall target="sm-b" />
<antcall target="sm-c" />
<antcall target="sm-bc" />
<antcall target="sv-b" />
<antcall target="sv-c" />
<antcall target="sv-bc" />
<antcall target="svm-bc" />
<antcall target="savm-bc" />
</target>

<target name="svg">
<antcall target="sv-b" />
<antcall target="sv-c" />
<antcall target="sv-bc" />
<antcall target="svm-bc" />
<antcall target="savm-bc" />
Expand Down Expand Up @@ -1134,6 +1155,7 @@
</copy>
<copy todir="dist">
<fileset file="web/js/src/MPWorker.js" />
<fileset file="web/js/src/SPWorker.js" />
</copy>
<copy todir="dist">
<fileset dir="web/samples" />
Expand Down
53 changes: 43 additions & 10 deletions web/js/src/SPWorker.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
/* expected input format for non-batch
var e.data = {};
e.data.id = "ID";
e.data.symbolID = "SFGPU----------";//A 15 character symbolID corresponding to one of the graphics in the MIL-STD-2525C
e.data.modifiers = {ModifiersUnits.T_UNIQUE_DESIGNATION_1:"T",MilStdAttributes.PixelSize:50};
var batch = [];//batch objects look like {id:"ID",symbolID:"SFGPU----------",modifiers:{ModifiersUnits.T_UNIQUE_DESIGNATION_1:"T",MilStdAttributes.PixelSize:50}};
var e.data = {base64:true, batch:batch};
e.data.batch[].id = "ID";
e.data.batch[].symbolID = "SFGPU----------";//A 15 character symbolID corresponding to one of the graphics in the MIL-STD-2525C
e.data.batch[].modifiers = {ModifiersUnits.T_UNIQUE_DESIGNATION_1:"T",MilStdAttributes.PixelSize:50};
e.data.format = "svg", "base64", "both"
if(format === "svg"), return object will have a .svg property with the svg string
if(format === "base64"), return object will have a .base64 property with the svg string like:
"data:image/svg+xml;base64,[SVG string after run through btoa()]
if(format === "both"), return object will have both properties.
*/

/* return object for non-batch
{
id:e.data.id,//same as what was passed in
symbolID:e.data.SymbolID,//resultant kml,json or error message
si:si//SVGInfo object
svg:svg string
anchorPoint:
symbolBounds:
imageBounds:
base64:svg string like: "data:image/svg+xml;base64,[SVG string after run through btoa()]".
}
*/

Expand All @@ -29,7 +36,7 @@ var e.data = {};



importScripts('sv-bc.js');
importScripts('sv-c.js');


armyc2.c2sd.renderer.utilities.ErrorLogger = {};
Expand Down Expand Up @@ -78,16 +85,30 @@ onmessage = function(e)
{
try
{

var returnVal = null;
if(e.data.batch && e.data.batch.length > 0)
{
var batch = e.data.batch;
var returnBatch = [];
var len = e.data.batch.length;
var item = null;

for(var i = 0; i < len; i++)
{
si = armyc2.c2sd.renderer.MilStdSVGRenderer.Render(batch[i].symbolID,batch[i].modifiers,e.data.fontInfo);
returnBatch.push({id:batch.id,symbolID:batch.symbolID,svg:si.getSVG(),anchorPoint:si.getAnchorPoint(),symbolBounds:si.getSymbolBounds(),bounds:si.getSVGBounds()});
item = batch[i];
si = armyc2.c2sd.renderer.MilStdSVGRenderer.Render(item.symbolID,item.modifiers,e.data.fontInfo);
returnVal = {id:batch.id,symbolID:batch.symbolID,anchorPoint:si.getAnchorPoint(),symbolBounds:si.getSymbolBounds(),bounds:si.getSVGBounds()};
if(e.data.format === "base64")
returnVal.base64 = si.getSVGDataURI();
else if(e.data.format === "both")
{
returnVal.base64 = si.getSVGDataURI();
returnVal.svg = si.getSVG();
}
else
returnVal.svg = si.getSVG();

returnBatch.push(returnVal);
}
if(si !== null)
{
Expand All @@ -105,7 +126,19 @@ onmessage = function(e)
if(si !== null)
{
//return results
postMessage({id:e.data.id,symbolID:e.data.symbolID,svg:si.getSVG(),anchorPoint:si.getAnchorPoint(),symbolBounds:si.getSymbolBounds(),bounds:si.getSVGBounds()});
returnVal = {id:e.data.id,symbolID:e.data.symbolID,svg:si.getSVG(),anchorPoint:si.getAnchorPoint(),symbolBounds:si.getSymbolBounds(),bounds:si.getSVGBounds()};

if(e.data.format === "base64")
returnVal.base64 = si.getSVGDataURI();
else if(e.data.format === "both")
{
returnVal.base64 = si.getSVGDataURI();
returnVal.svg = si.getSVG();
}
else
returnVal.svg = si.getSVG();

postMessage(returnVal);
}
else
{
Expand Down
34 changes: 27 additions & 7 deletions web/js/src/SVGWW.html

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions web/js/src/armyc2/c2sd/renderer/SinglePointSVGRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,14 +411,14 @@ return{
returnSVG += svgElements[k];
}

returnSVG += seGroupUnit;

if(svgElementsDOM.length > 0)
{
returnSVG += svgElementsDOM[0];
returnSVG += svgElementsDOM[1];
}

returnSVG += seGroupUnit;

//make group with translation
var shiftX = -imageBounds.getX();
var shiftY = -imageBounds.getY();
Expand All @@ -443,7 +443,7 @@ return{
}
else
{
returnSVG = '<svg width="' + imageBounds.getWidth() + 'px" height="' + imageBounds.getHeight() + 'px" viewbox="0 0 ' + imageBounds.getWidth() + ' ' + imageBounds.getHeight() + '" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" version="1.1">';
returnSVG = '<svg width="' + imageBounds.getWidth() + 'px" height="' + imageBounds.getHeight() + 'px" viewbox="0 0 ' + imageBounds.getWidth() + ' ' + imageBounds.getHeight() + '" preserveAspectRatio="xMidYMid" xmlns="http://www.w3.org/2000/svg" version="1.1">';
returnSVG += seGroupUnit;
returnSVG += '</svg>';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ armyc2.c2sd.renderer.utilities = armyc2.c2sd.renderer.utilities || {};
/** @class */
armyc2.c2sd.renderer.utilities.RendererSettings = (function () {

var _Version = "0.2.3";
var _Version = "0.2.4";
//outline approach. none, filled rectangle, outline (default),
//outline quick (outline will not exceed 1 pixels).
var _SymbologyStandard = 0,
Expand Down
2 changes: 1 addition & 1 deletion web/js/src/armyc2/c2sd/renderer/utilities/SVGInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ armyc2.c2sd.renderer.utilities.SVGInfo = function (svg, centerPoint, symbolBound
{
uri = this._svg.replace(/%/g,"%25");
uri = uri.replace(/#/g,"%23");//# to %23 for FF
uri = uri.replace(/"/g,"%22"); //" to %22 for EDGE, IE wont take SVG from a datauri
uri = uri.replace(/"/g,"%22"); //" to %22 for EDGE
uri = uri.replace(/</g,"%3C");
uri = uri.replace(/=/g,"%3D")
uri = uri.replace(/>/g,"%3E");
Expand Down
Loading

0 comments on commit 68e905d

Please sign in to comment.