Skip to content

Commit

Permalink
Fixed set icon size for mil std icons in Leaflet . #299 fixed in branch
Browse files Browse the repository at this point in the history
  • Loading branch information
alberto-acevedo committed Jun 26, 2017
1 parent 1bcba69 commit 4877084
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 35 deletions.
39 changes: 35 additions & 4 deletions src/mapengine/leaflet/js/leaflet-map-engine.debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -2040,12 +2040,40 @@ emp.engineDefs.leafletMapEngine = function (args) {
};

engineInterface.settings.mil2525.icon.size.set = function (transaction) {
var oEmpObject;
var sCoreId;

instanceInterface.iMilStdIconSize = transaction.items[0];
var oEmpObject, sCoreId,
iIconSize = 32, txtIconSize;

try {
txtIconSize = transaction.items[0].iconSize;
switch (txtIconSize)
{
case emp3.api.enums.IconSizeEnum.TINY:
iIconSize = leafLet.utils.iconPixelSize.TINY;
break;
case emp3.api.enums.IconSizeEnum.SMALL:
iIconSize = leafLet.utils.iconPixelSize.SMALL;
break;
case emp3.api.enums.IconSizeEnum.MEDIUM:
iIconSize = leafLet.utils.iconPixelSize.MEDIUM;
break;
case emp3.api.enums.IconSizeEnum.LARGE:
iIconSize = leafLet.utils.iconPixelSize.LARGE;
break;
default:
iIconSize = leafLet.utils.iconPixelSize.MEDIUM;
break;
}

if (instanceInterface.iMilStdIconSize === iIconSize)
{
return;
}
else
{
instanceInterface.iMilStdIconSize = iIconSize;
}


for (sCoreId in instanceInterface.mapEngObjectList) {
if (!instanceInterface.mapEngObjectList.hasOwnProperty(sCoreId)) {
continue;
Expand Down Expand Up @@ -2398,6 +2426,9 @@ emp.engineDefs.leafletMapEngine = function (args) {
break;
case "brightness":
break;
case "iconSize":
engineInterface.settings.mil2525.icon.size.set (transaction);
break;
}
}
if (previousRenderSettings.enabled) {
Expand Down
2 changes: 1 addition & 1 deletion src/mapengine/leaflet/js/lib/leaflet-src.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ leafLet.internalPrivateClass.MilStdFeature = function() {
}
}

oMainModifiers.SIZE = this.getEngineInstanceInterface().iMilStdIconSize;
oMainModifiers[msa.PixelSize] = this.getEngineInstanceInterface().iMilStdIconSize;
if (this.isSelected()) {}

if (L.Browser.canvas) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
var oStringModifiers = leafLet.utils.milstd.longModifiers;
var oLongToShortModifierName = leafLet.utils.milstd.stringToModifiers;
var o2525ModifierToLong = leafLet.utils.milstd.o2525ModifierToLong;

var publicInterface = {
oModifiers: {},
getAMValueCount: function()
Expand All @@ -16,7 +16,7 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
{
this.oModifiers[o2525Modifiers.DISTANCE] = [];
}

return this.oModifiers[o2525Modifiers.DISTANCE].length;
},
getAMValue: function(iIndex)
Expand All @@ -25,9 +25,9 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
{
return NaN;
}

var dValue = this.oModifiers[o2525Modifiers.DISTANCE][iIndex];

switch (oMilStdFeature.getUnits())
{
case leafLet.utils.Units.FEET:
Expand Down Expand Up @@ -60,7 +60,7 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
{
this.oModifiers[o2525Modifiers.AZIMUTH] = [];
}

return this.oModifiers[o2525Modifiers.AZIMUTH].length;
},
getANValue: function(iIndex)
Expand All @@ -69,16 +69,16 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
{
return NaN;
}

var dValue = this.oModifiers[o2525Modifiers.AZIMUTH][iIndex];

switch (oMilStdFeature.getAzimuthUnits())
{
case leafLet.utils.AngleUnits.MILS:
dValue = dValue * leafLet.utils.DEGREE_PER_MILS;
break;
}

return dValue;
},
setANValue: function(iIndex, dValue)
Expand All @@ -96,7 +96,7 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
}
else
{
this.oModifiers[o2525Modifiers.AZIMUTH].push(dValue);
this.oModifiers[o2525Modifiers.AZIMUTH].push(dValue);
}
},
getXValueCount: function()
Expand All @@ -105,7 +105,7 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
{
this.oModifiers[o2525Modifiers.ALTITUDE_DEPTH] = [];
}

return this.oModifiers[o2525Modifiers.ALTITUDE_DEPTH].length;
},
getXValue: function(iIndex)
Expand All @@ -114,16 +114,16 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
{
return NaN;
}

var dValue = this.oModifiers[o2525Modifiers.ALTITUDE_DEPTH][iIndex];

switch (oMilStdFeature.getAltitudeUnits())
{
case leafLet.utils.Units.FEET:
dValue = Math.round(dValue * leafLet.utils.FEET_PER_METERS);
break;
}

return dValue;
},
setXValue: function(iIndex, dValue)
Expand All @@ -134,20 +134,20 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
dValue = Math.round(dValue * leafLet.utils.METERS_PER_FEET);
break;
}

if (iIndex < this.getXValueCount())
{
this.oModifiers[o2525Modifiers.ALTITUDE_DEPTH][iIndex] = dValue;
}
else
{
this.oModifiers[o2525Modifiers.ALTITUDE_DEPTH].push(dValue);
this.oModifiers[o2525Modifiers.ALTITUDE_DEPTH].push(dValue);
}
},
toModifiers: function()
{
var oNewModifiers = {};

for (var sModifier in this.oModifiers)
{
if (!this.oModifiers.hasOwnProperty(sModifier)) {
Expand All @@ -158,22 +158,22 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
oNewModifiers[sModifier] = emp.helpers.copyObject(this.oModifiers[sModifier]);
}
}

return oNewModifiers;
},
toLongModifiers: function()
{
var sLongModifier;
var oNewModifiers = {};

for (var sModifier in this.oModifiers) {
if (!this.oModifiers.hasOwnProperty(sModifier)) {
continue;
}
if (this.oModifiers[sModifier] !== undefined)
{
sLongModifier = o2525ModifierToLong[sModifier];
sLongModifier = (o2525ModifierToLong[sModifier])?o2525ModifierToLong[sModifier]: sModifier;

switch (sModifier)
{
case o2525Modifiers.STANDARD:
Expand All @@ -185,13 +185,13 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
}
}
}

return oNewModifiers;
}
};

var sShortName;

for (var sProp in args)
{
if (!args.hasOwnProperty(sProp)) {
Expand All @@ -214,7 +214,7 @@ leafLet.typeLibrary.MilStdModifiers = function(oFeature, args)
{
sShortName = oLongToShortModifierName[sProp];
}

switch (sProp)
{
case oStringModifiers.STANDARD:
Expand Down
5 changes: 4 additions & 1 deletion src/mapengine/leaflet/js/utils/leaflet-eng.utils.geoJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,12 @@ leafLet.utils.geoJson = (function () {
var dOpacity = parseInt("0x" + oFeatureProperties.fillColor.substr(0, 2)) / 255.0;
oProperties.fillOpacity = dOpacity;
}
if (oFeatureProperties.hasOwnProperty('lineWidth')) {
if (oFeatureProperties.hasOwnProperty('lineWidth') && oFeatureProperties.lineWidth & oFeatureProperties.lineWidth !== null ) {
oProperties.weight = parseInt(oFeatureProperties.lineWidth);
}
else{
oProperties.weight = 3 ;
}
if (oFeatureProperties.hasOwnProperty('iconUrl')) {
sURL = (instanceInterface.bUseProxy ?
instanceInterface.getProxyURL() + "?" + "mime=image/*&url=" + escape(oFeatureProperties.iconUrl) :
Expand Down
14 changes: 10 additions & 4 deletions src/mapengine/leaflet/js/utils/leaflet-eng.utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ leafLet.utils.FEET_PER_METERS = 3.28084;
leafLet.utils.MILS_PER_DEGREE = (6400.0 / 360.0);
leafLet.utils.DEGREE_PER_MILS = (360.0 / 6400.0);

leafLet.utils.iconPixelSize = {};
leafLet.utils.iconPixelSize.TINY = 16;
leafLet.utils.iconPixelSize.SMALL = 24;
leafLet.utils.iconPixelSize.MEDIUM = 32;
leafLet.utils.iconPixelSize.LARGE = 48;

leafLet.utils.AltitudeModeAbbr = function(sMode) {
var sText = "";

Expand Down Expand Up @@ -137,13 +143,13 @@ leafLet.utils.wrapCoordinates = function(oMapBoundry, oLatLngList, bWrappedAlrea
var bCoordWrapped = bWrappedAlready || false;
var empBoundary = new leafLet.typeLibrary.EmpBoundary(oMapBoundry);
var bIDLinView = empBoundary.containsIDL();

//console.log("Start wrapCoordinte");

for (iIndex = 0; iIndex < iCoorCnt; iIndex++) {
oLatLngList[iIndex] = oLatLngList[iIndex].wrap();
lng = oLatLngList[iIndex].lng;

bLnginView = empBoundary.containsCoordiante(oLatLngList[iIndex]);

if (bIDLinView) {
Expand All @@ -167,7 +173,7 @@ leafLet.utils.wrapCoordinates = function(oMapBoundry, oLatLngList, bWrappedAlrea
tempLng = (empBoundary.getWest() + 180.0);
tempLng += (180.0 - empBoundary.getEast());
tempLng = tempLng / 2.0;

if ((empBoundary.getWest() - tempLng) >= -180) {
tempLng = empBoundary.getWest() - tempLng;
if (lng < tempLng) {
Expand Down

0 comments on commit 4877084

Please sign in to comment.