Skip to content

Commit

Permalink
Merge pull request #37 from snkashis/disable_scale
Browse files Browse the repository at this point in the history
bypass scale locking to available factors
  • Loading branch information
Jesse Eichar committed Mar 11, 2013
2 parents 6810e3f + e493d06 commit 3ff9ff3
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 7 deletions.
3 changes: 3 additions & 0 deletions docs/configuration.txt
Expand Up @@ -55,6 +55,7 @@ Here is the general structure:
?connectionTimeout: 30000 MF_V1.2
?socketTimeout: 180000 MF_V1.2
?outputFilename: Mapfish-print MF_V1.2
?disableScaleLocking: false

?security:
? - !basicAuth
Expand Down Expand Up @@ -123,6 +124,8 @@ If the 'outputFilename' parameter is defined in the main body then that name wil
* outputFilename: "host-${time}.pdf" # results in host-1:11:14_PM.pdf (actual output depends on local of server)
* outputFilename: "host-${yyMMdd-hhmmss}"# results in host-111213-011154.pdf (actual output depends on local of server)

"disableScaleLocking" allows you to bypass the choosing of scale from the available factors, and simply use the suggested value produced inside MapBlock.java.

Security
--------
Both Keys and Security are options for accessing protected services. Keys are currently for Google maps premium accounts and Security is for other types and is more general Currently only BasicAuth is supported but other strategies can easily be added
Expand Down
26 changes: 21 additions & 5 deletions src/main/java/org/mapfish/print/config/Config.java
Expand Up @@ -83,6 +83,7 @@ public class Config {
private int connectionTimeout = 40*60*1000; // 40 minutes //30*1000;

private boolean tilecacheMerging = false;
private boolean disableScaleLocking = false;

private List<SecurityStrategy> security = Collections.emptyList();

Expand Down Expand Up @@ -285,13 +286,20 @@ public void validate() {
* @return The first scale that is bigger or equal than the target.
*/
public int getBestScale(double target) {
target *= BEST_SCALE_TOLERANCE;
for (Integer scale : scales) {
if (scale >= target) {
return scale;
if (this.disableScaleLocking) {
Double forcedScale = target;
return forcedScale.intValue();
}
else {
target *= BEST_SCALE_TOLERANCE;
for (Integer scale : scales) {
if (scale >= target) {
return scale;
}
}
return scales.last();
}
return scales.last();

}

public synchronized OrderedResultsExecutor<MapTileTask> getMapRenderingExecutor() {
Expand Down Expand Up @@ -378,6 +386,14 @@ public boolean isTilecacheMerging() {
return tilecacheMerging;
}

public void setDisableScaleLocking(boolean disableScaleLocking) {
this.disableScaleLocking = disableScaleLocking;
}

public boolean isDisableScaleLocking() {
return disableScaleLocking;
}

public void setSocketTimeout(int socketTimeout) {
this.socketTimeout = socketTimeout;
}
Expand Down
Expand Up @@ -136,7 +136,7 @@ public Transformer createTransformer(RenderingContext context, PJsonObject param
// (maxY - minY) / (DistanceUnit.PT.convertTo(height, unitEnum))));
}

if (!context.getConfig().isScalePresent(scale)) {
if (!context.getConfig().isDisableScaleLocking() && !context.getConfig().isScalePresent(scale)) {
throw new InvalidJsonValueException(params, "scale", scale);
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/mapfish/print/map/MapChunkDrawer.java
Expand Up @@ -72,7 +72,7 @@ public void renderImpl(Rectangle rectangle, PdfContentByte dc) {
PJsonArray layers = parent.getJSONArray("layers");
String srs = parent.getString("srs");

if (!context.getConfig().isScalePresent(transformer.getScale())) {
if (!context.getConfig().isDisableScaleLocking() && !context.getConfig().isScalePresent(transformer.getScale())) {
throw new InvalidJsonValueException(params, "scale", transformer.getScale());
}

Expand Down

0 comments on commit 3ff9ff3

Please sign in to comment.